nested table using ng-repeat

后端 未结 2 1363
梦毁少年i
梦毁少年i 2020-12-17 19:44

What I\'m trying to do is repeat three levels.

Demo: http://plnkr.co/edit/qXLcPHXDlOKZYI5jnCIp?p=preview

相关标签:
2条回答
  • 2020-12-17 20:13

    You could try something like this, depending on the steady state of your models.

    <body>
    
    <table>
      <thead>
        <tr>
          <td>Block</td>
          <td>Column</td>
          <td ng-repeat="unit in building.ownBlock[0].ownColumn[0].ownUnit[0]">Unit</td>
          <td>Action</td>
        </tr>
      </thead>
      <tbody ng-repeat="block in building.ownBlock">
        <tr ng-repeat="column in block.ownColumn">
          <td>{{block.name}}</td>
          <td>{{column.number}}</td>
          <td ng-repeat="unit in column.ownUnit">{{unit.number}} - ? empty</td>
          <td><button ng-click="edit(unit)">Edit</button></td>
        </tr>
      </tbody>
    </table>
    <pre>
      {{toedit|json}}
    </pre>
    

    0 讨论(0)
  • 2020-12-17 20:13

    you will want to use the new ng-repeat-start and ng-repeat-end directives which were added in Angular 1.2. see the doco for examples.

    http://docs.angularjs.org/api/ng.directive:ngRepeat

    0 讨论(0)
提交回复
热议问题