の「取得」プロパティを読み取ることができません:ここERROR TypeError: Cannot read property 'get' of undefined
は私のコードです:フィールドの値を取得FormGroup:私は「passwordConfirm」フィールドの検証を作るしようとしているが、私はスタンジェのエラーを取得し、未定義
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
}
例外TypeErrorが
カスタムバリデーターで 'if(!this.loginForm){return null}'を試してください。 – Alex
何も起こりません。 – sandum
非常に奇妙ですが、this.loginForm.controls ['controlname']。値 –