(IF you want to excute passwordValidator you need to add '()' to your Validator Function example password1: new
FormControl("",[Validators.required,this.passwordValidator()]), Even
though it will throw error because FormGroup you used inside
will not have a reference to the formData password1 and password2)
If you want to compare two input field you need to use formGroup inside formGroup because if you do not use form group for the formGroup will not hold object like this.
value: Object
email1: "data"
email2: ""
__proto__: Object
https://angular.io/guide/form-validation#custom-validators Use This Ref for Implement ComparePassword and Email
/** A hero's name can't match the given regular expression */
export function forbiddenNameValidator(nameRe: RegExp): ValidatorFn {
return (control: AbstractControl): {[key: string]: any} | null => {
const forbidden = nameRe.test(control.value);
return forbidden ? {'forbiddenName': {value: control.value}} : null;
};
input type="email".