0
我試圖動態加載選項列表到選擇輸入。 我得到的錯誤是:Ionic2 - 無法執行'元素''setAttribute':'[[ngModel]]'不是一個有效的屬性名稱
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>