简体   繁体   English

Angular 7-具有未指定名称属性的表单控件无值访问器

[英]Angular 7 - No value accessor for form control with unspecified name attribute

I'm getting this error on my Angular 7 app and I don't know why. 我在Angular 7应用程序中遇到此错误,我不知道为什么。 Even with some researches it seems that this error doesn't make sense. 即使进行了一些研究,似乎该错误也没有道理。

This is what I have: 这就是我所拥有的:

<mat-form-field>
     <input matInput placeholder="Name" name="name" [(ngModel)]="data.name" [disabled]="inputReadonly" ngDefaultControl > 
</mat-form-field>

I've tried with and withoud ngDefaultControl on mat-form-field and/or input, with and without the name attribute and to move [(ngModel)] on input. 我已经尝试过在mat-form-field和/或输入上使用ngDefaultControl,并且不使用name属性,并在输入上移动[(ngModel)]。 Nothing is changed, I'm still receiving the same error. 什么都没改变,我仍然收到相同的错误。

ngModel has to be specified on the input , not on the mat-form-field . ngModel必须在input指定,而不是在mat-form-field The only purpose of mat-form-field is to apply some Material CSS mat-form-field的唯一目的是应用一些Material CSS

请确保您有MatFormFieldModuleMatInputModule在进口app.module.ts并在声明@NgModule({... imports:[MatFormFieldModule,MatInputModule, ...],...}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 以Angular格式显示img会显示“没有用于未指定名称属性的窗体控制的值访问器” - Displaying img in Angular form gives “No value accessor for form control with unspecified name attribute” Angular 8:表单控件,表单控件没有值访问器,名称为:'StartDateForm' - Angular 8: Form-Control, No value accessor for form control with name: 'StartDateForm' Angular form group:找不到具有未指定name属性的控件 - Angular form group: cannot find control with unspecified name attribute 使用Angular时表单元素是否需要name属性? - Is name attribute required on form elements when using Angular? 获取表单提交按钮值属性值的角度 - Get form submit button value attribute value in angular 如何使用Validator和Control Value Accessor正确实现嵌套表单? - How to properly implement nested forms with Validator and Control Value Accessor? 如果在表单标签中使用 ngModel,则必须设置 name 属性,或者必须在 ngModelOptions 中将表单控件定义为“独立” - If ngModel is used within a form tag, either the name attribute must be set or the form control must be defined as ‘standalone’ in ngModelOptions 窗体中的Angular 2自定义控件,默认值为[object Object] - Angular 2 custom control inside form, default value is [object Object] 如何在角度反应形式控件中添加小数,其值从 1 和更大开始 - how to add decimal in angular reactive form control with value starting with 1 and greater 在循环下从具有相同name属性的html表单获取值 - Getting Value from html form with the same name attribute under Loop
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM