user8048949
user8048949

Reputation:

How to push data in array stored in the Firebase using angularfire2?

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.

Upvotes: 0

Views: 2484

Answers (1)

Tim Hovius
Tim Hovius

Reputation: 742

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

this.user.push({description: "new Item"});

Upvotes: 1

Related Questions