1

how do i order it to display this array in the dropdown??

enter image description here

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>
4
  • Whats the type of traveldest here? Commented Jul 11, 2018 at 11:38
  • @Dhy46 you data seems in object format, not an array format?? Commented Jul 11, 2018 at 12:07
  • @eduPeeth traveldest: any = []; Commented Jul 11, 2018 at 12:41
  • @Sanoj_V I do not know I just get that data, i do not know in ionic v2 what's the problem because if i try with ionic v1 data it can appear in the dropdown. Commented Jul 11, 2018 at 12:46

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

1 Comment

save my day !!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.