离子选择Ionic 2中的动态选项?

hap*_*der 6 ionic2 ionic2-select angular

我正在开发Ionic 2中的应用程序.我需要以动态的方式添加离子选择选项,但我对可能非常简单的事情感到难过.这是我的代码片段.

<ion-select [(ngModel)]="classifications" (ngModelChange)="updateSelectedValue($event)">
 <ion-option *ngFor="#key of classifications" value="key" [checked]="true">{{key}}</ion-option>
Run Code Online (Sandbox Code Playgroud)

this.classifications = this.local.get('classifications')._result;
    console.log('classifications: '+ this.local.get('classifications')._result);


updateSelectedValue(event:string):void {
   this.selectedObject = JSON.parse(event);
   console.log('selectedObject: '+this.selectedObject);
}
Run Code Online (Sandbox Code Playgroud)

控制台日志的输出:

classifications: ["Any","Agriculture, Forestry, And Fishing","Mining","Construction","Manufacturing","Transportation, Communications, Electric, Gas, And Sanitary Services","Wholesale Trade","Retail Trade","Finance, Insurance, And Real Estate","Services","Public Administration "]
Run Code Online (Sandbox Code Playgroud)

我也得到了例外.

EXCEPTION: Cannot find a differ supporting object '["Any","Agriculture, Forestry, And Fishing","Mining","Construction","Manufacturing","Transportation, Communications, Electric, Gas, And Sanitary Services","Wholesale Trade","Retail Trade","Finance, Insurance, And Real Estate","Services","Public Administration "]' in [classifications in JobsearchPage@30:17]
Run Code Online (Sandbox Code Playgroud)

编辑:

它没有设定其选择的价值.我在Angular 1中做过这个.

<select id="classificationId"  data-role="listview" data-inset="true" ng-options="classification as classification for classification in classifications " ng-model="classification" x-ng-change="update(classification)">
<option value=''>Classifications</option></select><select id="classificationId" data-role="listview" data-inset="true" ng-options="classification as classification for classification in classifications " ng-model="classification" x-ng-change="update(classification)"><option value=''>Classifications</option></select>
Run Code Online (Sandbox Code Playgroud)

编辑(从评论到答案)

export class JobsearchPage { 
    selectedClassification:string; 
    constructor(http: Http, 
        nav: NavController, 
        messagesService:MessagesService, navParams:NavParams) { 
      this.http = http;
      this.messagesService = messagesService; 
      this.nav = nav; 
      this.classifications = new Array("t9it", 'uitut');
      console.log('STP selected'+selectedClassification); 
  } 
} 
Run Code Online (Sandbox Code Playgroud)

Gün*_*uer 2

我不使用 Ionic,但我很确定ngModel应该指向一个保存(或分配给)所选选项的字段,而不是整个可能选项列表

<ion-select [(ngModel)]="selectedClassification" (ngModelChange)="updateSelectedValue($event)">
 <ion-option *ngFor="#key of classifications" value="key" [checked]="true">{{key}}</ion-option>
Run Code Online (Sandbox Code Playgroud)
class MyComponent {
  selectedClassification:string;
}
Run Code Online (Sandbox Code Playgroud)