离子2。 ion-option 未在视觉上选中

Ionic2. ion-option is not checked Visually

我在 ion-list 中有这个 ion-option:

  <ion-select [(ngModel)]="year">
    <ion-option checked="true">
      {{year}}
    </ion-option>
    <ion-option *ngFor="#year of years">
      {{year}}
    </ion-option>
  </ion-select>

在Page/Component里面我设置:

this.year  = '2016';
this.day = 30;
this.month = 'Jan';

视觉上没有检查,技术上是。:

这些是选项:

看来它一定是数字而不是字符串... 我该如何解决?

我认为你想要完成的是这样的:

  <ion-select [(ngModel)]="yearModel">
      <ion-option *ngFor="#year of years" value="{{year}}">
      {{year}}
    </ion-option>
  </ion-select>

这将显示 years 数组中的年份列表,并将检查 yearModel 中的年份(为清楚起见,我使用了不同的变量名称)。

例如,如果您在页面文件中执行 this.yearModel="2016",它将检查 2016 年。