错误angular2 Error: If ngModel is used within a form tag...

来源:互联网 发布:lumia800下载软件 编辑:程序博客网 时间:2024/05/01 00:45

Error: 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}">

input 标签没有 name
添加上name=”xxxName”

<input placeholder="phone" [(ngModel)]="person.phone" #personPhone = "ngModel" maxlength="11"  required >

修改后

<input placeholder="phone" [(ngModel)]="person.phone" #personPhone = "ngModel" maxlength="11" name="phone"   required >

无报错

阅读全文
0 0
原创粉丝点击