Reputation: 258
I have this ion-option
inside a ion-list
:
<ion-select [(ngModel)]="year">
<ion-option checked="true">
{{year}}
</ion-option>
<ion-option *ngFor="#year of years">
{{year}}
</ion-option>
</ion-select>
And inside the Page/Component I set:
this.year = '2016';
this.day = 30;
this.month = 'Jan';
Visually it's not checked, technically, it is.:
These are the options:
As it seems it must be a number not string... How can I solve this?
Upvotes: 0
Views: 75
Reputation: 2372
I think what you are trying to accomplish is something like this:
<ion-select [(ngModel)]="yearModel">
<ion-option *ngFor="#year of years" value="{{year}}">
{{year}}
</ion-option>
</ion-select>
This will show the list of years in your years
array, and will check the one you have in yearModel
(I used a different variable name for clarity).
For example if you do this.yearModel="2016"
in you page file, it will check the year 2016.
Upvotes: 1