我想比较表单的两个值是否相同。我有这个
if(this.holdForm.value != this.positionForm.value){
this.enableButton = true;
}else{
this.enableButton = false;
}
但它不起作用。它不会使 enableButton 为真。
更新:
this.positionForm = this.fb.group({
'name' : [position.name, Validators.required],
'remark': position.remark
});
this.holdForm = this.fb.group({
'name' : position.name,
'remark': position.remark
});
this.positionForm.valueChanges.subscribe(data => {
this.onValueChanged(data);
if(this.data.process == 'register'){
this.enableButton = true;
}else if(this.data.process == 'update' && this.holdForm.value != this.positionForm.value){
this.enableButton = true;
}else{
this.enableButton = false;
}
});