简体   繁体   English

没有用于角度控制的格式控件的值访问器(角度5中具有未指定的名称属性)

[英]No value accessor for form control with unspecified name attribute in angular 5

HTML code HTML代码

<li class="dropdownfilter" *ngIf="this.arr.inclues('Male')" (click)="getValueGender('Male',1,)" [(ngModel)]="M"><a>Male</a></li>

I'm facing the below exception 我面临以下异常

ERROR Error: No value accessor for form control with unspecified name attribute

So I have added 所以我加了

<li class="dropdownfilter" name="gendermale" *ngIf="this.arr.inclues('Male')" (click)="getValueGender('Male',1,)" [(ngModel)]="M"><a>Male</a></li>

Now facing the below exception 现在面临以下异常

ERROR Error: No value accessor for form control with name: 'gendermale'

I'm facing this exception in many places of my code. 我在代码的许多地方都遇到了这个异常。

<div class="col-sm-8 col-xs-8 contact">
    <input  id="passphn{{bus.busServiceId}}" (keyup)="onKeyPress($event)" class="form-control contact-number" type="text" [(ngModel)]="contactNumber" name="contact-number" placeholder="Phone" required pattern="(?<!\d)\d{10}(?!\d)" minlength="10" maxlength="10" />
    <div class="shake-tooltip-web-mobile" *ngIf="webMobileError != ''">{{webMobileError}}</div> <!-- Facing the same exception here -->
</div>

<div class="panel-body" *ngIf="dropingView == 'show'"> <!-- Here too -->

First of all, you can't access with this.x in html. 首先,您无法使用html中的this.x进行访问。

<li class="dropdownfilter" *ngIf="arr.inclues('Male')" (click)="getValueGender('Male',1)"><a>Male</a></li>

Secondly, li tag doesnt have name attribute nor supports [(ngModel)] because it requires value property. 其次,li标签没有名称属性,也不支持[[ngModel)],因为它需要value属性。 ngModel is an angular build in directive. ngModel是一个有角度的内置指令。 Two-way binding uses the syntax as [()], Property binding uses the syntax [] and Event binding uses the syntax as parenthesis (). 双向绑定将语法用作[()],属性绑定使用语法[],事件绑定使用语法作为括号()。

暂无
暂无

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

相关问题 没有用于未指定名称属性Angular 2的表单控件的值访问器 - No value accessor for form control with unspecified name attribute Angular 2 Angular 7-具有未指定名称属性的表单控件无值访问器 - Angular 7 - No value accessor for form control with unspecified name attribute Angular 7 Reactive 表单“没有未指定名称属性的表单控件的值访问器” - Angular 7 Reactive forms “No value accessor for form control with unspecified name attribute” 以Angular格式显示img会显示“没有用于未指定名称属性的窗体控制的值访问器” - Displaying img in Angular form gives “No value accessor for form control with unspecified name attribute” ERROR 错误:在开关上没有具有未指定名称属性的表单控件的值访问器 - ERROR Error: No value accessor for form control with unspecified name attribute on switch 没有用于ngControl的未指定名称属性的表单控件的值访问器 - No value accessor for form control with unspecified name attribute for ngControl 错误错误:具有未指定名称属性的表单控件没有值访问器 - ERROR Error: No value accessor for form control with unspecified name attribute 有角材料Datepicker引发多个自定义值访问器将表单控件与未指定名称属性相匹配 - Angular material Datepicker throws More than one custom value accessor matches form control with unspecified name attribute ERROR 错误:在 angular 中绑定轮播时,没有具有未指定名称属性的表单控件的值访问器 - ERROR Error: No value accessor for form control with unspecified name attribute when bind carousel in angular 表单控件错误:错误错误:没有具有未指定名称属性的表单控件的值访问器 - form control error:ERROR Error: No value accessor for form control with unspecified name attribute
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM