You can use rxjs operators to check values.
ValueChanges of FormGroup The ValueChanges event of FormGroup or FormArray is fired, whenever the value of any of its child controls value changes.
$dirty means the user has changed the input value, $invalid means the address itself is invalid. Therefore the error is only shown if the user has actively changed the input value to either an empty or invalid value.
I have some form and button to save it. The button must only be enabled when there are unsaved changes (inputs) on the form.
<form>
<div>
... (inputs)
<span (click)="save()"> Save </span>
</div>
</form>
Is there some build-in mechanism for form dirty check in Angular 5? What is the easiest way to implement this scenario ?
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