I have an Angular form:<button mat-flat-button color="primary" [disabled]='Updateurlflag || !appawareform.dirty' *ngIf="title== 'Edit'" (click)="editappawareinfo(drawer)">Update</button>In my Edit drawer, there will be three fields. They are Id, IP, and Port. While editing, I disabled the field Id. The user can change only IP/Port or both.If the user does not change any value in the Edit drawer, I disabled the button Update.But the problem is if I erase 1 symbol in fields and then write it again (the value is the same, but form was changed),I have to again disable the button Update. But how can I do this? 解决方案 If you use ReactiveForms, it's easy control when a formControl changeImagine you has a formControl with "updateOn:blur"formControl=new FormControl('',{ updateOn: 'blur' });You can subscribe to change using pairwise rxjs operator likethis.formControl.valueChanges.pipe( startWith(this.formControl.value), //it's necesary send a first value pairwise()) //the pairwise make the "magic" .subscribe(([old,value])=>{ if (old!=value) { console.log("I change from "+old+" to "+value) } })Well, I use a FormControl, you can use a FormGroup or a FormArray and subscribe to valueChangesSee a stackblitz 这篇关于仅当在Angular中更改字段时才提交数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 09-05 21:49