【发布时间】:2018-04-15 22:42:15
【问题描述】:
我正在尝试在单击按钮后更新 firebase 中的列表(增加列表中的值),但是,每当我单击按钮时,除非我关闭页面选项卡,否则该值会不断增加而不会停止。
onRecipeUpvote(recipe: Recipe)
{
// get list with -> name: recipe.name
let listRecipe = this.ngFireDB.list<Recipe>('/recipes', ref => ref.orderByChild('name').equalTo(recipe.name));
listRecipe.snapshotChanges().map(actions => {
return actions.map(action => ({ key: action.key, ...action.payload.val() }));
}).subscribe(items => {
return items.map(item => {
// Increment its current upvotes by 1
listRecipe.update(item.key, { upvotes: item.upvotes + 1 });
});
});
}
【问题讨论】:
标签: angular typescript rxjs angularfire2 angularfire5