我想檢查是否我的表格中至少有一個字段發生了變化。如果這種情況屬實,disableButton
將設置爲true和false如果有沒有更改的形式。下面是我當前的代碼:角度2:禁用按鈕如果表格中有變化
// this.hold is an array that temporary holds the previous values of
// the form for comparison of the changes in form
if(this.data.process == 'update') {
for(const f in form.value){
if (form.value[f] == this.hold[f])
this.disableButton = true;
else
this.disableButton = false;
}
}
的問題是,當ALL字段 改變了按鈕只會關閉。我應該在我的狀況或循環中添加什麼?
仍然無效@YounisArM – Char
當值相同時,你將它設置爲true,這與你想要的相反,我已經改變了代碼,現在嘗試 –
你不需要改變布爾值。但是這工作。謝謝@YounisArM – Char