gpt4 book ai didi

ionic-framework - Ionic2 - 无法在 'setAttribute' : 'Element' is not a valid attribute name 上执行 '[[ngModel]]'

转载 作者:行者123 更新时间:2023-12-01 09:48:53 31 4
gpt4 key购买 nike

我正在尝试将选项列表动态加载到选择输入中。
我得到的错误如下:

Error in ./PhonePage class PhonePage - caused by: Failed to execute 'setAttribute' on 'Element': '[[ngModel]]' is not a valid attribute name.

这是我的 phone.ts 代码
@Component({
selector: 'page-phone',
templateUrl: 'phone.html'
})

export class PhonePage {

selectedValue: number;
optionList: Array<{value:number, text: string}> = [];

constructor(public navCtrl: NavController, public navParams: NavParams) {

this.navCtrl = navCtrl
this.initOptionList();

}

moveToEmail(){

this.navCtrl.push(EmailPage)
}

initOptionList(){
this.optionList.push({value: 1,text:"FR +33"});
this.optionList.push({value: 1,text:"BE +32"});
this.optionList.push({value: 1,text:"LU +352"});
this.optionList.push({value: 1,text:"CH +41"});
this.optionList.push({value: 1,text:"GB +44"});
this.optionList.push({value: 1,text:"IE +353"});
this.optionList.push({value: 1,text:"NL +31"});
this.optionList.push({value: 1,text:"ES +34"});
this.optionList.push({value: 1,text:"PT +351"});
this.optionList.push({value: 1,text:"IT +39"});
this.optionList.push({value: 1,text:"DE +49"});
this.optionList.push({value: 1,text:"DK +45"});
this.optionList.push({value: 1,text:"MT +356"});
this.optionList.push({value: 1,text:"GP +590"});
this.optionList.push({value: 1,text:"GF +594"});
this.optionList.push({value: 1,text:"MQ +596"});
this.optionList.push({value: 1,text:"YT +262"});
this.optionList.push({value: 1,text:"NC +687"});
this.optionList.push({value: 1,text:"PF +689"});
this.optionList.push({value: 1,text:"RE +262"});
}
}

这是我尝试循环的 html 页面的代码。
我将选项推送到数组中。
<ion-select [[ngModel]]="selectedValue">
<ion-option *ngFor="let item of optionList" value="{{item.value}}">{{item.text}}</ion-option>
</ion-select>

最佳答案

您必须申报ngModel[(ngModel)]="selectedValue" (括号内的括号)
当您已声明为 [[ngModel]]="selectedValue" (括号内的括号)。

关于ionic-framework - Ionic2 - 无法在 'setAttribute' : 'Element' is not a valid attribute name 上执行 '[[ngModel]]',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42277140/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com