Search code examples
angularjsangularjs-ng-repeat

Nested ng-repeat not displaying the correct value


I am working on a scenario where i am using nested ng-repeat to display the json values in html table.Attached the plunker plnkr.co/edit/qC6v8nOP4iFgjlxezTa1?p=preview.I am not able to see the last column values properly.


Solution

  • You have no problems with AngularJS, but with HTML, try this variant:

    <table width="100%">
     <thead>
       <tr>
         <th>Id:</th>
         <th>Age:</th>
         <th>Subjects:</th>
         <th>Only Lecturer Name</th>
      </tr>
     </thead>
     <tbody>
       <tr ng-repeat="x in student track by $index">
         <td>{{x.id}}</td>
         <td>{{x.age}}</td>
         <td>{{x.subjects}}</td>
         <td>
           <span ng-repeat="j in x.subjects">
             {{j.Lecturer}}
           </span>
         </td>
       </tr>
     </tbody>
    </table>