A
A
Anton Shvets2018-05-02 18:16:29
Angular
Anton Shvets, 2018-05-02 18:16:29

How to reset Angular Material form fields to remove validation error?

I have a form field

<mat-form-field >
  <input matInput 
    placeholder="Password" 
    [formControl]="passwordFormControl"
    [errorStateMatcher]="matcher"
    [(ngModel)]="password">
  <mat-error *ngIf="passwordFormControl.hasError('minlength')">Please enter at least 4 symbols</mat-error>
  <mat-error *ngIf="passwordFormControl.hasError('required')">Password is required</mat-error>
</mat-form-field>

After sending the data, I reset the value And I can not remove the message "Password is required" in any way. No manipulations help. How to do it correctly? this.password='';
passwordFormControl

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Shvets, 2018-05-02
@Xuxicheta

As always, I found the solution myself.
Need to dopasswordFormControl.setErrors(null)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question