Ich versuche, eine Validierung machen für „passwordConfirm“ Feld lesen, aber ich erhalte eine Stange Fehler: ERROR TypeError: Cannot read property 'get' of undefined
hier ist mein Code:FormGroup Feldwert zu erhalten: Typeerror: kann Eigenschaft ‚get‘ undefinierter
loginForm: FormGroup;
ngOnInit(){
this.loginForm = new FormGroup({
'email': new FormControl(null, [Validators.required, Validators.email]),
'password': new FormControl(null, Validators.required),
'passwordConfirm': new FormControl(null, [Validators.required, this.checkIfMatchingPasswords.bind(this)]),
});
}
checkIfMatchingPasswords() {
return this.loginForm.get('password').value === this.loginForm.get('passwordConfirm').value ? null : { notSame: true} // error
}
Versuchen Sie 'if (! This.loginForm) {return null}' in Ihrem benutzerdefinierten Validator. – Alex
Nichts passiert. – sandum
sehr seltsam, aber Sie könnten dies versuchen.loginForm.controls ['Steuerelementname']. Wert –