简体   繁体   English

Angular 反应 forms,输入错误:没有名称的表单控件的值访问器

[英]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>的模块

Detailed Explanation详细说明

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.

相关问题 Angular 7 Reactive 表单“没有未指定名称属性的表单控件的值访问器” - Angular 7 Reactive forms “No value accessor for form control with unspecified name attribute” 使用反应形式的 ionic 5 和 Angular 9 出现错误“没有名称的表单控件的值访问器” - Error 'No value accessor for form control with name' with ionic 5 and Angular 9 using reactive form 没有用于角度控制的表单控制的值访问器,角度7中的名称错误 - No value accessor for form control with name error in angular 7 Angular 5 mdbootstrap自动完成错误“名称为&#39;autocomplete&#39;的表单控件无值访问器” - Angular 5 mdbootstrap autocomplete error “ no value accessor for form control with name: 'autocomplete'” Angular 单元测试(带 Getter):错误:没有带有名称的表单控件的值访问器 - Angular Unit Test (with Getter): Error: No value accessor for form control with name Angular 单元测试:错误:表单控件没有值访问器,名称为:'phoneNumber' - Angular unit Test: Error: No value accessor for form control with name: 'phoneNumber' Angular 2 mat-dialog中带有“ Reactive Froms”名称的窗体控件没有值访问器,名称为“ rating” - No value accessor for form control with name: 'rating' in Angular 2 mat-dialog with Reactive Froms 没有名称控件的值访问器-Angular 5 - No value accessor for form control with name - Angular 5 Angular 反应式表单错误:必须为表单控件提供一个名称值: - Angular reactive Form error: Must supply a value for form control with name: Angular 8:表单控件,表单控件没有值访问器,名称为:'StartDateForm' - Angular 8: Form-Control, No value accessor for form control with name: 'StartDateForm'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM