本文整理汇总了TypeScript中angularfire2/angularfire2.FirebaseObjectObservable.update方法的典型用法代码示例。如果您正苦于以下问题:TypeScript FirebaseObjectObservable.update方法的具体用法?TypeScript FirebaseObjectObservable.update怎么用?TypeScript FirebaseObjectObservable.update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类angularfire2/angularfire2.FirebaseObjectObservable
的用法示例。
在下文中一共展示了FirebaseObjectObservable.update方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: restaurantVote
/**
* @description Performs a vote for or against a restaurant
* @param {Object} restaurant object to determine which restaurant is voted for/against
*/
restaurantVote(restaurant){
let isVotePresent = false;
let dateKey = Utility.getTodayString();
if(this.name === undefined) return;
if(this.dates[dateKey][restaurant.id] === undefined){
this.dates[dateKey][restaurant.id] = {};
}
Object.keys(this.dates).forEach(key => {
if(!this.dates[key] || !this.dates[key][restaurant.id]) return;
if(this.dates[key][restaurant.id][this.name]) isVotePresent = true;
});
if(isVotePresent){
// vote present, vote against it
this.dates[dateKey][restaurant.id][this.name] = !this.dates[dateKey][restaurant.id][this.name];
} else {
// vote not present, add it as positive
this.dates[dateKey][restaurant.id][this.name] = true;
}
delete this.dates.$key;
this.votes.update(this.dates);
}