[英]Angular reactive forms, input Error: No value accessor for form control with name
I have an input defined as below我有一个定义如下的输入
<form [formGroup]="loginForm"">
<ion-input [formControlName]="'email'"></ion-input>
My component declares the form as我的组件将表单声明为
this.loginForm = this.formBuilder.group({
email: ['', Validators.compose([Validators.required, Validators.email])],
password: ['', Validators.required]
});
Yet at runtime angular is throwing this error然而在运行时 angular 抛出这个错误
ERROR Error: No value accessor for form control with name: 'email'
错误错误:没有名称为“电子邮件”的表单控件的值访问器
I have ensured I have both ReactiveFormsModule & FormsModule in my modules Import我已确保我的模块导入中同时包含 ReactiveFormsModule 和 FormsModule
Any other ideas what I'm missing?我还缺少什么其他想法吗?
You have not imported the module where <ion-input>
was declared您尚未导入声明
<ion-input>
的模块
With Angular 9+, fullTemplateTypeCheck
is set to false
hence angular will not complain See Below statement from github Ivy is not complaining about unknown element inside ng-template #36171对于 Angular 9+,
fullTemplateTypeCheck
设置为false
,因此 angular 不会抱怨 请参阅以下来自 github的声明 Ivy 不会抱怨 ng-template 中的未知元素 #36171
This is due to an architectural change in Ivy.
这是由于 Ivy 的架构变化。 In the previous compiler (ViewEngine), the check for unknown elements would occur during parsing of the template.
在以前的编译器 (ViewEngine) 中,对未知元素的检查将在模板解析期间发生。 In Ivy, templates are parsed independently from the corresponding NgModule, so information on components/directives in scope is not available.
在 Ivy 中,模板是独立于相应的 NgModule 进行解析的,因此无法获得 scope 中有关组件/指令的信息。 Instead, checking of elements is pushed into the template type checking phase and it's currently affected by the type checker's configuration.
相反,元素检查被推入模板类型检查阶段,并且当前受类型检查器配置的影响。 With fullTemplateTypeCheck set to true however, it should descend into templates to check them (when it's false, it won't for backwards compatibility reasons)
但是,将 fullTemplateTypeCheck 设置为 true 时,它应该进入模板以检查它们(当它为 false 时,出于向后兼容的原因,它不会)
The Engine will not complain about the unknown element but will complain about the valueAccessor引擎不会抱怨未知元素,但会抱怨 valueAccessor
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.