如何使用angularfire2推送存储在Firebase中的数组中的数据?

时间:2017-10-19 05:30:51

标签: arrays database angular firebase angularfire2

我使用angularfire2在firebase数据库中存储数据。我需要将数据添加到存储在数据库中的数组,如下所示:

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

依此类推我需要的东西。 但就我而言,数据看起来像这样:

enter image description here

这是我的代码:

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

  

当用户输入新位置时,我需要输入新数据到数组而不是插入新数组。

感谢。

1 个答案:

答案 0 :(得分:1)

您正在推送一个数组,尝试推送一个对象。示例:

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