I'm trying to reset a form after I've added a value.
Form Code Snippet
<form [formGroup]="addAttributeForm" fxLayout="column">
<mat-form-field>
<input matInput formControlName="title" placeholder="Title" required>
<mat-error>This field is required</mat-error>
</mat-form-field>
</form>
In the component
onSubmit(form: FormGroup) {
// do work
form.reset();
}
What I'm observing:
- The form values are set to empty.
- But the validation messages are still displayed from mat-error.
- I've tried
form.markAsPristine(),form.markAsUntouched()and combining all three.
How can I reset the form so the mat-error is not displayed?