@karthikcp wrote:
I was populating my ionic list from the json response as given below:
{
“engineering”: [{
“0”: {
“id”: 1,
“name”: “Amrita School of Engineering”
},
“location”: “Kollam”
},
{
“0”: {
“id”: 3,
“name”: “Amrita School of Medicine”
},
“1”: {
“id”: 4,
“name”: “Amrita School of Engineering”
},
“location”: “Kozhikode”
}
],
“medicine”: [{
“0”: {
“id”: 2,
“name”: “Amrita School of Medicine”
},
“location”: “Kollam”
},
[]
]
}
My Ionic list is:<ion-list no-lines> <ion-list-header *ngFor="let details of searchResults?.engineering"> <div style="background-color:#2f6b8c;padding-top:10px;padding-bottom:10px;padding-left:5px;color:white">{{details.location}}</div> <button ion-item *ngFor="let detail of details?.0" (click)="itemSelected(detail.id)"> <span style="text-transform: capitalize;">{{detail.name}}</span> </button> </ion-list-header> </ion-list>
Using this i am able to print the location object data while each location has different list. In The above JSON you can see Kollam in engineering has only one college name so ‘0’, while kozhikode in engineering has 2 colleges so 0,1. if n colleges then 0 to n array will be there… But how could i populate this in a list? Any help?
Posts: 1
Participants: 1