如何使用 angularfire2 将数据推送到存储在 Firebase 中的数组中?
How to push data in array stored in the Firebase using angularfire2?
我正在使用 angularfire2 将数据存储在 firebase 数据库中。我需要将数据添加到存储在数据库中的数组中,如下所示:
places:
0:"new Item"
1:"new Item",
2:"new Item"
.
.
.
等等,这就是我需要的。
但就我而言,数据如下所示:
这是我的代码:
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.
谢谢。
您正在压入一个数组,请尝试压入一个对象。示例:
this.user.push({description: "new Item"});
我正在使用 angularfire2 将数据存储在 firebase 数据库中。我需要将数据添加到存储在数据库中的数组中,如下所示:
places:
0:"new Item"
1:"new Item",
2:"new Item"
.
.
.
等等,这就是我需要的。 但就我而言,数据如下所示:
这是我的代码:
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.
谢谢。
您正在压入一个数组,请尝试压入一个对象。示例:
this.user.push({description: "new Item"});