Reputation: 681
I have ionic select box and options are populating like below., I want to set the first value of the collection to be selected by default. please help
<ion-select interface="popover">
<ion-option *ngFor="let cps of selectedCP" value="{{cps.ID}}" checked="true" (ionSelect)="selectAssets($event, cps)">{{cps.Name}}</ion-option>
</ion-select>
Upvotes: 0
Views: 950
Reputation: 222522
You need to set the default value using [(ngModel)]
<ion-select [(ngModel)]="selectedP" interface="popover">
<ion-option *ngFor="let cps of selectedCP" value="{{cps.ID}}" checked="true" (ionSelect)="selectAssets($event, cps)">{{cps.Name}}</ion-option>
</ion-select>
and in .TS
this.selectedP= selectedCP[0];
Upvotes: 1