how do i order it to display this array in the dropdown??
my.html
<ion-item>
<img src="assets/img/travel/city.png" width="25" height="30" item-start>
<ion-label stacked>Pilih Kota</ion-label>
<ion-select [(ngModel)]="shuttledestination2" name="shuttledestination2" interface="action-sheet">
<ion-option *ngFor="let data of traveldest" value="{{ data.id }}"><b>{{ data.label }}</b></ion-option>
</ion-select>
</ion-item>
Your traveldest
clearly is an object of objects and not an arry, you can see by the image where the second line you have {1{...}, 2{...}, 3{...}}
.
That you need to do is convert this object to an array before assigning it to traveldest
, you can easy do this by using Object.values(yourObject)
, so you can do this:
this.traveldest = Object.values(yourReceivedObject);
yourReceivedObject
is the response from your HTTP call or anything that is returning your results.
Hope this helps.