不,这不是一个重复的问题.你看,在SO和Github中有很多问题和问题规定我将这个指令添加到一个带有[(ngModel)]指令但不包含在表单中的标签中.如果我不添加它我会收到一个错误:
ERROR Error: No value accessor for form control with unspecified name attribute
Run Code Online (Sandbox Code Playgroud)
好的,如果我把这个属性放在那里,错误就消失了.可是等等!没人知道它的作用!Angular的文档根本没有提到它.当我知道我不需要它时,为什么需要值访问器?该属性如何连接到值访问器?这个指令做了什么?什么是价值追求者以及如何使用它?
为什么每个人都继续做他们不理解的事情?只需添加这行代码即可,谢谢,这不是编写好程序的方法.
然后.我在Angular上阅读了关于表单的两个大型指南,以及关于以下内容的部分ngModel:
你知道吗?没有提到任何值访问器或ngDefaultControl.它在哪里?
升级到RC5后,我们开始收到此错误:
ngModel cannot be used to register form controls with a parent formGroup directive. Try using
formGroup's partner directive "formControlName" instead. Example:
<div [formGroup]="myGroup">
<input formControlName="firstName">
</div>
In your class:
this.myGroup = new FormGroup({
firstName: new FormControl()
});
Or, if you'd like to avoid registering this form control, indicate that it's standalone in ngModelOptions:
Example:
<div [formGroup]="myGroup">
<input formControlName="firstName">
<input [(ngModel)]="showMoreControls" [ngModelOptions]="{standalone: true}">
</div>
Run Code Online (Sandbox Code Playgroud)
看起来在RC5中两者不能再一起使用,但我找不到替代解决方案.
以下是产生异常的组件:
<select class="field form-control" [formGroup]="form" [(ngModel)]="cause.id" [name]="name">
<option *ngFor="let c of causes" [value]="c.text">{{c.text}}</option>
</select>
Run Code Online (Sandbox Code Playgroud) 在组件加载到angular4应用程序的下面组件中,我不断收到错误:
ng:///HeaderModule/HeaderComponent.ngfactory.js:334错误:没有带有未指定名称属性的表单控件的值访问器
我试过删除ngModel和value属性但没有任何工作.
我假设问题是标题.component.html.下面是html
<!-- Notification area-->
<li class="dropdown">
<a href="#" data-toggle="dropdown" class="dropdown-toggle" (click)="changeNotificationStatus()">
<i class="glyphicon glyphicon-bell"></i>
<span class="visible-xs-inline">Notifications</span>
<span class="badge badge-sm up bg-danger pull-right-xs" [hidden]="notificationCount<=0" [(ngModel)]="notificationCount"></span>
</a>
<div class="dropdown-menu w-xl animated fadeInUp">
Run Code Online (Sandbox Code Playgroud)
不确定导致问题的原因.如果有人可以指出这个问题会有所帮助.
谢谢
I would like to add a checkbox in a Material Design table in Angular 4, it would be under the column Publish. The problem is that the checkbox doesn't show in the table just the text with and error message
"No value accessor for form control with unspecified name attribute"

Here is my code:
<div class="mat-table-container mat-elevation-z8">
<mat-table #table [dataSource]="assessmentManualList">
<ng-container cdkColumnDef="documentID">
<mat-header-cell *cdkHeaderCellDef> </mat-header-cell>
<mat-cell *cdkCellDef="let row">
<button mat-icon-button [matMenuTriggerFor]="menu">
<mat-icon>more_vert</mat-icon>
</button>
<mat-menu #menu="matMenu">
<button mat-menu-item>
<mat-icon><i class="material-icons">content_copy</i></mat-icon>
<span>Copy …Run Code Online (Sandbox Code Playgroud) 我正在准备一个 stackblitz 来解决我在子父母沟通方面遇到的问题,但在此过程中,我遇到了一个不同的问题,即我收到以下错误:No value accessor for form control with name: 'endDateFC'。对于 ,也会发生这种情况startDateFC。
我从 SO 尝试了以下操作:
ReactiveFormsModule和FormsModuleFormsModule。我只在以下位置导入app.modules.ts根据:表单控件没有值访问器
formControlName位于值访问器元素上我的代码有什么问题吗?这是 stackblitz:https://stackblitz.com/edit/primeng-calendar-v-zdd3of ?file=src/app/postpone-dialog/postpone-dialog.component.ts