0

I'm using angularfire2 to store data in the firebase database. I need to add data to an array stored in the database to be like this:

places: 0:"new Item" 1:"new Item", 2:"new Item" . . .

and so on and that what i need. But in my case the data look like this:

enter image description here

this is my code:

this.user = this.db.list("/Users/"+ this.currentUserId+'/places'); this.user.push(["new Item"]);

When the user enter new place, I need new data enter to the array and not a new array inserted.

Thanks.

1 Answer 1

1

You are pushing an array, try to push an object instead. Example:

this.user.push({description: "new Item"});
Sign up to request clarification or add additional context in comments.

4 Comments

hi, it looks like ` places: asdjasdjdjasas description:"new Item"`
I need the key to be generate by the firebase 0 1 2
and exactly under the places title
Firebase has no native support for arrays. If you store an array, it really gets stored as an "object" with integers as the key names - firebase.googleblog.com/2014/04/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.