Angular2如果在表单标签中使用ngModel,则必须设置name属性或窗体

前端之家收集整理的这篇文章主要介绍了Angular2如果在表单标签中使用ngModel,则必须设置name属性或窗体前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我从角度2得到这个错误
core.umd.js:5995 EXCEPTION: Uncaught (in promise): Error: Error in app/model_exposure_currencies/model_exposure_currencies.component.html:57:18 caused by: 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.

      Example 1: <input [(ngModel)]="person.firstName" name="first">
      Example 2: <input [(ngModel)]="person.firstName" [ngModelOptions]="{standalone: true}">



  <td *ngFor="let lag of ce.lags">
                  <div class="form-group1">
                    <input name="name" [(ngModel)]="lag.name" [ngModelOptions]="{standalone: true}"  class="form-control" pattern="[0-9]*(\.[0-9]+)?" required>
                  </div>

                </td>

这是我如何使用表单标签

<form #f="ngForm" (ngSubmit)="onSubmit()">
如果使用ngForm,则具有[(ngModel)] =“”的所有输入字段必须具有带值的属性名称
<input [(ngModel)]="firstname" name="something">
原文链接:https://www.f2er.com/angularjs/144790.html

猜你在找的Angularjs相关文章