加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

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

发布时间:2020-12-17 08:18:23 所属栏目:安全 来源:网络整理
导读:我从角度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
我从角度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">

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读