mardi 14 février 2017

Nested JSON and AngularJS confusion

Basically I have a PHP quasi-API that results in this JSON:

{"0":{"id":"325","course":"{\"0\":{\"id\":\"31\",\"title\":\"Ticket Seller     II\",\"code\":\"STN\"},\"nm\":1}","batch":"29","start_date":"2016-04-20 08:30:00","end_date":"2016-05-17 17:00:00"}

But while I retrieved the first JSON array by the JS script:

var prog=[];
var res=response.data;

for(var i=0; i<=res['nm'];i++){


     prog.push(res[i]);

}

vm.events = prog;

I have no idea how to retrieve the nested JSON, "course". I have this Angular script:

ng-repeat="event in table1.events"

But something like event.course[0].title gives out an error. Nesting a repeat like

<span ng-repeat="title in event.course">

Still doesn't work. How do I retrieve it?

Aucun commentaire:

Enregistrer un commentaire