pushp
pushp

Reputation: 2502

angular how to check is the model is changed or not

I am using angular 4 and i want check that is any value is changed by user or not? In my page there are more than 100 control(textbox ,dropdown and editable grid)

I need to check only if any value is changed or not.

Upvotes: 0

Views: 263

Answers (1)

Christian Benseler
Christian Benseler

Reputation: 8065

You can subscribe to the formControl's valuesChanged property.

yourFormControl.valuesChanged.subscribe( value => {
   console.log(value); //will output the new value from yourFormControl
});

Note that the form itself has this property.

this.yourForm = this.formBuilder.group( /* etc... */)
this.yourForm.valuesChanged.subscribe( form => {
   console.log(form); //will output the new value from the entire form, every time one of its child is changed
});

Upvotes: 3

Related Questions