Angularjs +使用ng-repeat加载多个数组

时间:2014-01-26 10:17:02

标签: angularjs angularjs-directive angularjs-ng-repeat

如何使用ng repeat

将多个数组数据加载到指令templateURL
<div> <table> <tr> <td>h1</td> <td>v1</td> </tr> </table> </div>
<div> <table> <tr> <td>h2</td> <td>v2</td> </tr> </table> </div>
<div> <table> <tr> <td>h3</td> <td>v3</td> </tr> </table> </div>

DEMO LINK

指令控制人:

 $scope.data  =[[{ h:'H1', v:'V1'}][{ h:'H2', v:'V2'}][{ h:'H3', v:'V3'}]];
 $scope.updateData = $scope.data;

模板结构:

  <div ng-repeat="fields in updateData">
      <table>
      <tr>
          <td>{{f.h}}</td>
          <td>{{f.v}}</td>
      </tr>
    </table></div>

1 个答案:

答案 0 :(得分:2)

只需在ng-repeat

上添加其他<tr>即可
<div ng-repeat="fields in updateData">
      <table>
           <tr ng-repeat="f in fields">
              <td>{{f.h}}</td>
              <td>{{f.v}}</td>
           </tr>
       </table>
  </div>

DEMO