【发布时间】:2017-06-23 05:31:07
【问题描述】:
我想使用 AngularFire2 在 firebase 中增加一条记录,下面是我的方法:
const productsQuery = this.af.database.list('/products/'+productKey,{ preserveSnapshot: true });
const productUpdate = this.af.database.list('/products');
productsQuery.subscribe(snapshots => {
snapshots.forEach(snapshot => {
if (snapshot.key == "quantity") {
productUpdate.update(productKey,{quantity: snapshot.val()+1});
}
});
});
但不是只增加一次数量,而是产生一个无限循环,“数量”记录变得太大,
有帮助吗?
非常感谢,
【问题讨论】:
标签: angular firebase firebase-realtime-database angularfire2