我正在使用离子和角度的混合应用程序,使用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 .