【发布时间】:2017-12-15 06:44:14
【问题描述】:
我正在尝试比较 2 个 firebase 对象 countregs 和 maxregs。我想返回一个像这样的布尔值,但无论值如何,我总是得到真实的。 如果打印显示 countregs = 3 和 maxregs = 5 的值,那么它应该返回 false。
谢谢!
getMaxRegs(company: string) {
var snapshotMaxRegs = this.db.object(`companies/${company}/maxregs`,{ preserveSnapshot: true})
snapshotMaxRegs.subscribe(snapshot => {
console.log('maxRegs = '+ snapshot.val())
return snapshot.val();
});
}
getCountRegs(company: string){
var snapshotCountRegs = this.db.object(`companies/${company}/countregs`,{ preserveSnapshot: true})
snapshotCountRegs.subscribe(snapshot => {
console.log('currRegs = '+ snapshot.val())
return snapshot.val();
});
}
maxRegsReached(company: string){
if (this.getCountRegs(company) >= this.getMaxRegs(company)
|| this.getCountRegs(company) == this.getMaxRegs(company))
{
return true;
} else {
return false;
}
}
【问题讨论】:
标签: angular typescript firebase firebase-realtime-database angularfire2