本文整理匯總了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);
}