When I change a value in an input field, the corresponding form-control is set to dirty. When I revert my change (by typing in the input field) the form-control stays dirty. Is this intended, is this a bug or do I do something wrong?
Well, yes it's intended to work that way since:
A control is
dirty
if the user has changed the value in the UI. (docs entry)
..and not if the value is different from the starting value.
In case you want to revert the dirty state you could use the markAsPristine()
(docs entry) on your AbstractControl
. (eg trigger it by click on a button or when subscribing to the valueChanges
observable of the AbstractControl
and compare the new value to a previously stored one...)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With