Basically I have password and confirmation inputs, and I want the confirmation input to validate if it's the same as the password input.. You know how it works.
My problem: I can't figure out how to update the confirmation validator every time the password input is changed. My current code never updates it.
component.ts:
export class LoginComponent
confirmPassword = '';
newPasswordForm = new FormControl('', [
Validators.required, Validators.minLength(5), Validators.maxLength(256),
Validators.nullValidator, Validators.pattern(pwRegexp)]);
confirmPasswordForm = new FormControl('', [
Validators.required, Validators.pattern(this.confirmPassword)]);
and html:
<mat-form-field>
<input #newPassword matInput placeholder="Password" [formControl]="newPasswordForm" [type]="hide2 ? 'password' : 'text'" [(ngModel)]="meme">
<mat-icon matSuffix (click)="hide2 = !hide2">{{hide2 ? 'visibility' : 'visibility_off'}}</mat-icon>
<mat-error *ngIf="newPasswordForm.invalid">{{getNewPasswordErrorMessage()}}</mat-error>
</mat-form-field>
<mat-form-field>
<input matInput placeholder="Confirm password" [formControl]="confirmPasswordForm" [type]="hide3 ? 'password' : 'text'">
<mat-icon matSuffix (click)="hide3 = !hide3">{{hide3 ? 'visibility' : 'visibility_off'}}</mat-icon>
<mat-error *ngIf="confirmPasswordForm.invalid">{{getConfirmPasswordErrorMessage()}}</mat-error>
</mat-form-field>