I have password and confirmPassword fields that are built using FormBuilder:
public createAccountForm: FormGroup;
constructor(
private builder: FormBuilder,
)
this.createAccountForm = this.builder.group({
pass: this.builder.control('',
[
Validators.required
]),
confirmPass: this.builder.control('',
[
Validators.required,
CustomValidators.equivalent('pass') // the custom validators checks if pass and confirmPass is the same
]),
.............
});
----------------------
<input formControlName="pass" [(ngModel)]="model.pass" >
<input formControlName="confirmPass" >
This works OK. Now, I want to invoke the CustomValidators.equivalent('pass') when I change the pass input field.
How to do that?