How to iterate array of object in ion-card


#1

i have a json file consisting of an array of object.I m not able to display the content of the object of array in ion-card .
Json content are:
[
{
“rideId”: 10052,
“carModel”: “TEST”,
“carNumber”: “TEST 12 AC 1234”,
“capacity”: 3,
“available”: 3,
“tripType”: “HO”,
“fromDate”: 1514745000000,
“toDate”: 1517250600000,
“time”: 7200000,
“ownerId”: {
“employeeId”: 123456,
“firstName”: “Abhishek”,
“lastName”: “Sharma”,
“area”: “test”,
“address”: “test”,
“userType”: “owner”,
“mobile”: 123456789,
“picture”: null,
“email”: “”
}
},
{
“rideId”: 10053,
“carModel”: “TEST”,
“carNumber”: “TEST 12 AC 1234”,
“capacity”: 3,
“available”: 3,
“tripType”: “HO”,
“fromDate”: 1514745000000,
“toDate”: 1517250600000,
“time”: 7201000,
“ownerId”: {
“employeeId”: 123456,
“firstName”: “Abhishek”,
“lastName”: “Sharma”,
“area”: “test”,
“address”: “test”,
“userType”: “owner”,
“mobile”: 123456789,
“picture”: null,
“email”: “”
}
}
]

And my ts page content are:

@Component({
selector: ‘page-add-new-companion’,
templateUrl: ‘add-new-companion.html’,
})
export class AddNewCompanionPage {

list:any
data:any
constructor(public navCtrl: NavController, public navParams: NavParams) {
}

ionViewDidLoad() {
debugger;
console.log(‘ionViewDidLoad AddNewCompanionPage’);
this.list = localStorage.getItem(“NCList”);
this.data = JSON.parse(this.list);
//console.log(“list :” + this.data);
}

}

Also i have tried ng-repeat but there was no output…its shows blank page with no error.


#2

this is my html code…
i have also used ngRepeat no outcome…
if i do item.property…it say’s item undefined


#3

Hello,
maybe data = []; instead of data:any

Best regards, anna-liebt


#4

Got the code running.There was some JSON parsing issue.

Thanks anna-liebt.