0
<table class="table table-bordered">
<thead>
  <tr>
     <th></th>
     <th colspan="3" ng-repeat="d in $ctrl.otherdata">{{d.name}}</th>
   </tr>
   <tr>
     <th>User ID</th>
     ***** want to loop following 3 th***** 
     <th>ABC</th>
     <th>XYZ</th>
     <th>PQR</th>
    ***************************************
   </tr>

</thead>
<tbody>
  <tr ng-repeat="data in $ctrl.somedata">
     <td>{{data.name}}</td>
     <td>{{data.x}}</td>
     <td>{{data.y}}</td>
     <td>{{data.z}}</td>

   </tr>

</tbody>
</table>

Is it possible to loop following 3 th in ng-repeat based on length of $ctrl.otherdata?

<th>ABC</th>
<th>XYZ</th>
<th>PQR</th>

I tried but look like it is against web standard, I tried using DIV but look like it is not possible in table so any other alternative ?

Check attached image : this is what i am looking for throw loop using angular js

I want table like this using loop

1 Answer 1

3

This should work -

<table class="table table-bordered">
<thead>
  <tr>
     <th></th>
     <th colspan="3" ng-repeat="din $ctrl.otherdata">{{d.name}}</th>
   </tr>
   <tr>
      <th>User ID</th>
      <th ng-repeat-start="x in $ctrl.otherdata">ABC</th>
      <th>XYZ</th>
      <th ng-repeat-end>PQR</th>
    </tr>
  </thead>
  <tbody>
    <tr ng-repeat="data in $ctrl.somedata">
      <td>{{data.name}}</td>
      <td>{{data.x}}</td>
      <td>{{data.y}}</td>
      <td>{{data.z}}</td>

    </tr>

  </tbody>
</table>
Sign up to request clarification or add additional context in comments.

2 Comments

Excellent ! Great Answer ! Thank You !
Glad that it helped :)

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.