【发布时间】:2018-12-12 21:33:31
【问题描述】:
我正在使用 ionic 和 angular 开发一个混合应用程序,使用 angularfire2 将数据存储到 firebase 数据库
上面是firebase中列表的图像,现在我想添加列表中每个节点的totalCalories
这是我的代码
let count = 0;
uList : Observable<any[]>;
this.uList = this.dbServ.getConsumedFoodList(this.authServ.getUID()).snapshotChanges();
this.uList.forEach(item => {
item.forEach(itemData => {
this.food = itemData.payload.val();
console.log(this.food.totalCalories);
count = count + this.food.totalCalories;
})
})
但计数中没有任何内容,它只给出 0。
【问题讨论】:
标签: firebase-realtime-database ionic3 angularfire2