I have a form with few data fields and two buttons.I want to enable the buttons only if the user makes some changes to the form. I have tried using:
this.for
first of all use "NgForm".
Then on the "onSubmit()" function do this -
onSubmit(myForm: NgForm): void {
let formControls = myForm.controls;
if(formControls.firstName.dirty) {
console.log("It's dirty");
}
else {
console.log("not dirty");
}
}
It will definitely work. You can print the whole "myForm" and see for yourselves what all options are available to use.