【发布时间】:2018-06-04 04:52:11
【问题描述】:
我想禁用带有条件的按钮,例如我已经用关键的日期制作了一个数据。我想禁用用于创建与我已经将其推送到 Firebase 的数据具有相同日期的新数据的按钮。我在 html 上的代码是这样的:
<button ion-button full (click)="submitLaporan()" color='secondary' [disabled]="isEnabled()">Buat laporan harian</button>
这是打字稿上的代码:
isEnabled()
{
this.db.list('/laporan/'+this.id).subscribe(laporan =>{
for(var i =0,j = 0;i<laporan.length;i++)
{
console.log("masuk laporan",laporan);
if(laporan[i].mydate == this.tanggal)
return false;
else
{
return true;
}
}
})
}
在函数isEnabled() 上我想查询我的firebase 中的所有数据,然后将其与日期进行比较,如果firebase 上的日期和ionic 上的日期具有相同的值,它应该返回false 并且按钮被禁用。但这根本不起作用。
我没有与 ionic 日期相同但按钮保持禁用的数据。它应该被启用。
【问题讨论】:
标签: typescript firebase ionic-framework firebase-realtime-database angularfire2