Reputation: 47
Following this article
But it seemed not to work on my json structure. Here is my json
$scope.trucks = [{
id: 4,
truckNumber: '50LD 02456',
driverName: 'Dẻo',
shipments: [{
id: 1,
routeCode: "THC-VinhHao",
trip: 2
}, {
id: 2,
routeCode: "THC-VinhHao(R)",
trip: 3
}, {
id: 3,
routeCode: "THC2-Hiệp Thành HM",
trip: 3
}]
}, {
id: 5,
truckNumber: '61C 03948',
driverName: 'Hưng',
shipments: [{
id: 4,
routeCode: "TBC-VBL HMo",
trip: 1
}, {
id: 5,
routeCode: "THC2-Hiệp Thành HM",
trip: 4
}]
}];
<ul>
<li data-ng-repeat="truck in trucks">
{{truck.truckNumber}}
<br />
<ul>
<li data-np-repeat="shipment in truck.shipments">{{shipment.routeCode}}</li>
</ul>
</li>
</ul>
Any help are appreciated. Thanks for reading.
Upvotes: 0
Views: 63
Reputation: 180
Change np-repeat to ng-repeat then it will work.
<ul>
<li data-ng-repeat="truck in trucks track by $index">
{{truck.truckNumber}}
<br />
<ul>
<li data-ng-repeat="shipment in truck.shipments track by $index">{{shipment.routeCode}}</li>
</ul>
</li>
</ul>
Upvotes: 1
Reputation: 580
Please make sure you have everything correctly spelled out. ng-repeat was misspelled.
<ul>
<li data-ng-repeat="truck in trucks">
{{truck.truckNumber}}
<br/>
<ul>
<li data-ng-repeat="shipment in truck.shipments">{{shipment.routeCode}}</li>
</ul>
</li>
</ul>
Upvotes: 1
Reputation: 14417
<ul>
<li data-ng-repeat="truck in trucks">
{{truck.truckNumber}}
<br />
<ul>
<li data-np-repeat="shipment in truck.shipments">{{shipment.routeCode}}</li>
</ul>
</li>
</ul>
There is a typo.
<li data-ng-repeat="shipment in truck.shipments">{{shipment.routeCode}}</li>
Upvotes: 0