通过多个级别的多个 ng-repeats-start 属性
Multiple ng-repeats-start attributes through multiple levels
我正在尝试使用 ng-repeat
遍历四个级别,但 ng-repeat
在第三个级别后失败。
如何使用 ng-repeat
进行多次重复?
<tbody ng-repeat="company in companies">
<tr>
<td>{{company.name}}</td>
</tr>
<tr ng-repeat-start="child in company.Children">
<td>{{child.name}}</td>
</tr>
<tr ng-repeat-start="child2 in child.Children">
<td>{{child2.name}}</td>
</tr>
<tr ng-repeat-end ng-repeat="child3 in child2.Children">
<td>{{child3.name}}</td>
</tr>
<tr ng-repeat-end></tr>
</tbody>
我试过这样结束两个循环:
<tr ng-repeat-end></tr>
<tr ng-repeat-end></tr>
但是,Angular 不检查是否必须关闭两个循环。你只能关闭一个循环,这是我的问题。
正如您在 this plunker 中看到的那样,您的代码对我来说工作得很好。但是当我尝试使用旧的 angular 版本(v1.2 之前)时出现错误。我不需要将您的代码更改为
<tr ng-repeat-end></tr>
<tr ng-repeat-end></tr>
我正在尝试使用 ng-repeat
遍历四个级别,但 ng-repeat
在第三个级别后失败。
如何使用 ng-repeat
进行多次重复?
<tbody ng-repeat="company in companies">
<tr>
<td>{{company.name}}</td>
</tr>
<tr ng-repeat-start="child in company.Children">
<td>{{child.name}}</td>
</tr>
<tr ng-repeat-start="child2 in child.Children">
<td>{{child2.name}}</td>
</tr>
<tr ng-repeat-end ng-repeat="child3 in child2.Children">
<td>{{child3.name}}</td>
</tr>
<tr ng-repeat-end></tr>
</tbody>
我试过这样结束两个循环:
<tr ng-repeat-end></tr>
<tr ng-repeat-end></tr>
但是,Angular 不检查是否必须关闭两个循环。你只能关闭一个循环,这是我的问题。
正如您在 this plunker 中看到的那样,您的代码对我来说工作得很好。但是当我尝试使用旧的 angular 版本(v1.2 之前)时出现错误。我不需要将您的代码更改为
<tr ng-repeat-end></tr>
<tr ng-repeat-end></tr>