Ionic framework Ionic2-错误-如果在表单标记中使用ngModel,则必须设置name属性或将表单控件定义为';独立';
我不确定是否理解在通过一系列选项填充我的选择列表时遇到的错误 这是我得到的错误Ionic framework Ionic2-错误-如果在表单标记中使用ngModel,则必须设置name属性或将表单控件定义为';独立';,ionic-framework,ionic2,Ionic Framework,Ionic2,我不确定是否理解在通过一系列选项填充我的选择列表时遇到的错误 这是我得到的错误 Error in ./PhonePage class PhonePage - 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
Error in ./PhonePage class PhonePage - 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}">
/PhonePage类PhonePage中的错误-由以下原因引起:
如果在表单标记中使用ngModel,则必须设置name属性或
表单控件必须在ngModelOptions中定义为“独立”。
例1:
例2:
这是我的html代码
<form>
<h2>Quel est votre numéro de téléphone?</h2>
<ion-list>
<ion-grid>
<ion-row>
<ion-col width-33>
<ion-item>
<ion-select [(ngModel)]="optionList">
<ion-option *ngFor="let item of optionList" value="{{item.text}}">{{item.text}}</ion-option>
</ion-select>
</ion-item>
</ion-col>
<ion-col>
<ion-item>
<ion-input type="text"></ion-input>
</ion-item>
</ion-col>
</ion-row>
</ion-grid>
</ion-list>
</form>
电话号码是多少?
{{item.text}
如果使用ngForm,则所有具有[(ngModel)]=”的输入字段必须具有带值的属性名称
如果使用ngForm,则所有具有[(ngModel)]=”的输入字段必须具有带值的属性名称
Prerak Tiwari的回答是正确的 这里只是一个小提示:我看到您将ion select绑定到“optionList”,但这只是您想要显示的选项列表,需要创建所有ion选项
您应该将ion select绑定到一个新参数,因为之后它将保留所选的ion选项。Prerak Tiwari的答案是正确的 这里只是一个小提示:我看到您将ion select绑定到“optionList”,但这只是您想要显示的选项列表,需要创建所有ion选项
您应该将ion select绑定到一个新参数,因为此后它将保留选定的ion选项。是的,您是对的。我想她把代码弄乱是为了解决发布的问题。她在前面的问题中使用了正确的标识符。接得好。是的,你是对的。我想她把代码弄乱是为了解决发布的问题。她在前面的问题中使用了正确的标识符。接得好。