I have an angular template driven form. and I want to reset all the validation error and make it as untouched without resetting the form. How to do that in angular? I have tried the following method
onAdd(form: NgForm) {
form.form.markAsPristine();
form.form.markAsUntouched();
}
but this doesn't work.
link:- https://stackblitz.com/edit/angular-ezixd4
current behavior:-
when I click to submit an empty form, all the field is marked with error and when I click add
it adds the field but the above function doesn't remove the error message.
expected behavior:-
when I click to submit an empty form, all the field is marked with error and when I click add
it adds the field and it should remove the error message on the form (or in the added files).
In this form, I am adding input field with add Button and I want to clear any error message before the user has the chance to interact with the form.