admin管理员组文章数量:1278854
I'm getting this error on my Angular 7 app and I don't know why. 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. Nothing is changed, I'm still receiving the same error.
I'm getting this error on my Angular 7 app and I don't know why. 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. Nothing is changed, I'm still receiving the same error.
Share Improve this question edited Aug 20, 2021 at 10:00 Guerric P 31.8k6 gold badges58 silver badges105 bronze badges asked Dec 17, 2018 at 10:24 DeooKDeooK 5453 gold badges8 silver badges25 bronze badges2 Answers
Reset to default 7ngModel
has to be specified on the input
, not on the mat-form-field
. The only purpose of mat-form-field
is to apply some Material CSS
make sure you have MatFormFieldModule
and MatInputModule
imported in your app.module.ts
and also declared in @NgModule({... imports:[MatFormFieldModule,MatInputModule, ...],...}
本文标签: javascriptAngular 7No value accessor for form control with unspecified name attributeStack Overflow
版权声明:本文标题:javascript - Angular 7 - No value accessor for form control with unspecified name attribute - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741289936a2370489.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论