我正在创建一个表格,并且我使用了反应式表格vallidation。它总是给我以下错误。我不知道出什么事了
这是错误
{
"resource": "/d:/angular/my-app/src/app/admin/login/login.component.html",
"owner": "_generated_diagnostic_collection_name_#1",
"severity": 8,
"message": "Identifier 'email' is not defined. The component declaration, template variable declarations, and element references do not contain such a member",
"source": "Angular",
"startLineNumber": 88,
"startColumn": 29,
"endLineNumber": 88,
"endColumn": 34
}
任何解决方案表示赞赏!
答案 0 :(得分:1)
最简单的方法可能是在组件中声明一个电子邮件变量。
email: AbstractControl
ngOnInit() {
this.loginForm = new FormGroup({
email: new FormControl('', Validators.required),
password: new FormControl('', Validators.required)
});
this.email = this.loginForm.controls.email;
}