Ionic selectable value from json file

Hi I’m trying to get ion-selectable value from json file
my code:

this.http.get(‘assets/airport_volume_airport_locations.json’).map(res => res.json()).subscribe(data => {

this.airports = data;

});

for (let index = 0; index < this.airports.length; index++) {

this.port=[{name:this.airports[index].Orig,value:this.airports[index].Orig},] ;
}
my json file:

[

{

“Orig”: “HEA”,

“Name”: “Herat”,

“TotalSeats”: 22041.971,

“Country Name”: “Afghanistan”,

“Airport1Latitude”: 34.20690155,

“Airport1Longitude”: 62.22669983

},

{

“Orig”: “JAA”,

“Name”: “Jalalabad”,

“TotalSeats”: 6343.512,

“Country Name”: “Afghanistan”,

“Airport1Latitude”: 34.40000153,

“Airport1Longitude”: 70.5

},

{

“Orig”: “KBL”,

“Name”: “Kabul International”,

“TotalSeats”: 1016196.825,

“Country Name”: “Afghanistan”,

“Airport1Latitude”: 34.56389999,

“Airport1Longitude”: 69.21389771

},

{

“Orig”: “KDH”,

“Name”: “Kandahar International”,

“TotalSeats”: 39924.262,

“Country Name”: “Afghanistan”,

“Airport1Latitude”: 31.50690079,

“Airport1Longitude”: 65.84750366

},

{

“Orig”: “MZR”,

“Name”: “Mazar-e-Sharif”,

“TotalSeats”: 58326.513,

“Country Name”: “Afghanistan”,

“Airport1Latitude”: 36.70420075,

“Airport1Longitude”: 67.20829773

},

{

“Orig”: “OAI”,

“Name”: “Bagram Airport”,

“TotalSeats”: 18016.614,

“Country Name”: “Afghanistan”,

“Airport1Latitude”: 34.94639969,

“Airport1Longitude”: 69.26499939

}, …

but the result is empty like this
sel

any help

Please post enough code to reproduce the problem (including the relevant HTML in the template).

1 Like

my HTML:

label

<ionic-selectable item-content

itemTextField=“name” (onChange)=“portChange4($event)” itemValueField=“value” [ngModelOptions]="{standalone: true}" [canSearch]=“true” [(ngModel)]=“selectedDisPort” [items]=“airports” >

my code:

this.http.get(‘assets/airport_volume_airport_locations.json’).map(res => res.json()).subscribe(data => {

this.airports = data;

});

What I meant in my previous post is this:

Assume that whoever is trying to help you has a scratchpad project that is generated by ionic start. Something that you can do to greatly improve the productivity of this conversation is to follow along yourself, playing the part of both the questioner and the answerer.

Create a scratch project, and copy just enough of your code into it that the problematic behavior is clearly evident. Then either commit it to a public source repository host like GitHub or Gitlab and post the URL or post enough of the code in the thread so that it is easy to just copy/paste the result into a scratch project.

2 Likes