【发布时间】:2017-12-30 22:29:02
【问题描述】:
我想检查我的表单中是否至少有一个字段被更改了。如果这种情况为真,disableButton 将设置为 true,如果表单中没有更改,则设置为 false。以下是我当前的代码:
// 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 字段为 改变了。我应该在条件或 for 循环中添加什么?
【问题讨论】:
标签: forms angular typescript field angular-forms