Access Denied Access Denied - 1 month ago 8
JSON Question

How to get arrays from .json Ionic 2 Angular 2

in applications where there is an array, and with it another 7 arrays, no I can not show in the template , tell me how to get arrays .json

Thank you all!

channel.json = comming with the name channel

{
"version": 3.1,
"get": true,
"programms1": [
{
"id": 1,
"img": "image.png",
"name": "name",
"about": "about"
},
{
"id": 2,
"img": "image.png",
"name": "name",
"about": "about"
},
{
"id": 3,
"img": "image.png",
"name": "name",
"about": "about"
}
],
"programms2": [
{
"id": 1,
"img": "image.png",
"name": "name",
"about": "about"
},
{
"id": 2,
"img": "image.png",
"name": "name",
"about": "about"
},
{
"id": 3,
"img": "image.png",
"name": "name",
"about": "about"
}
],
"programms3": [
{
"id": 1,
"img": "image.png",
"name": "name",
"about": "about"
},
{
"id": 2,
"img": "image.png",
"name": "name",
"about": "about"
},
{
"id": 3,
"img": "image.png",
"name": "name",
"about": "about"
}
],
"programms4": [
{
"id": 1,
"img": "image.png",
"name": "name",
"about": "about"
},
{
"id": 2,
"img": "image.png",
"name": "name",
"about": "about"
},
{
"id": 3,
"img": "image.png",
"name": "name",
"about": "about"
}
],
"programms5": [
{
"id": 1,
"img": "image.png",
"name": "name",
"about": "about"
},
{
"id": 2,
"img": "image.png",
"name": "name",
"about": "about"
},
{
"id": 3,
"img": "image.png",
"name": "name",
"about": "about"
}
],
"programms6": [
{
"id": 1,
"img": "image.png",
"name": "name",
"about": "about"
},
{
"id": 2,
"img": "image.png",
"name": "name",
"about": "about"
},
{
"id": 3,
"img": "image.png",
"name": "name",
"about": "about"
}
],
"programms7": [
{
"id": 1,
"img": "image.png",
"name": "name",
"about": "about"
},
{
"id": 2,
"img": "image.png",
"name": "name",
"about": "about"
},
{
"id": 3,
"img": "image.png",
"name": "name",
"about": "about"
}
]
}


Ps: comes an array of channel and has 7 arrays

Ionic Template

<ion-list>
<ion-item *ngIf="let channel channel.programms7">
<ion-icon name="play" item-left large></ion-icon>
<h2>{{channel.name}}</h2>
<p>{{channel.about}}</p>
</ion-item>
<ion-list


show me an one example gets an array on template!

Thanks to all

Answer

You can iterate through an array in template using ngFor directive:

<div *ngFor="let j of myJson.programms3">
    {{j.id}}
    {{j.img}}
    {{j.name}}
    {{j.about}}
</div>

Here's working Plunker.