Reputation: 9
Im trying to create ion-select with preselected value and generated options but Im facing problem, initial select is not displayed until I interact with select. I assume that this component is checking for available options to display based on given value and then generating options in *ngFor loop. Am I doing it wrong? Or is there any way to solve this problem?
<ion-select value="preselect.id">
<ion-select-option *ngFor="let item of itemList" [value]="item.id">
{{ item.name}}
</ion-select-option>
</ion-select>
Upvotes: 0
Views: 107
Reputation: 290
I have solved the same issue with adding ngModel .
<ion-select (click)="loadcurrency()" [(ngModel)]="selectedcurrency">
<ion-select-option *ngFor="let currency of currencies"
value="{{currency.name}}">{{currency.capital}}
</ion-select-option>
</ion-select>
And at .ts file
selectedcurrency = "aud";
loadcurrency() {
....//initialize the array for options
}
Upvotes: 0