单击按钮后,我正在尝试在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 });
});
});
}