0

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.

5
  • try using "ng-repeat", not "data-ng-repeat" or "data-np-repeat" Commented May 19, 2015 at 8:46
  • 3
    typo?? np-repeat??? Commented May 19, 2015 at 8:46
  • 1
    data-ng-repeat would be fine Commented May 19, 2015 at 8:47
  • Here is the working example jsfiddle.net/U3pVM/15706 Commented May 19, 2015 at 8:49
  • Thank you!!! This is my foolish fault!!! Commented May 19, 2015 at 8:50

3 Answers 3

1

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>
Sign up to request clarification or add additional context in comments.

3 Comments

ng-repeat is still wrongly spelled in the 2nd li ;-)
Dammit! haha - Thanks Jordumus
No problem @Van Le, please mark the answer as correct if everything is okay with you
1
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>

Comments

0
<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>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.