Javascript 对两个不同的对象使用ng repeat start和ng repeat end
我尝试使用两个不同的对象来表示ng repeat start和ng repeat end 例如:Javascript 对两个不同的对象使用ng repeat start和ng repeat end,javascript,angularjs,loops,angularjs-ng-repeat,Javascript,Angularjs,Loops,Angularjs Ng Repeat,我尝试使用两个不同的对象来表示ng repeat start和ng repeat end 例如: <tr ng-repeat-start="file in files"> <td class="name-col">{{file.name}}<br> </td> <td class="name-col">{{file.
<tr ng-repeat-start="file in files">
<td class="name-col">{{file.name}}<br>
</td>
<td class="name-col">{{file.progress}}</td>
</tr>
<tr ng-repeat-end="otherFile in otherFiles">
<td colspan="2">
{{otherFile.errors}}
</td>
</tr>
{{file.name}}
{{file.progress}
{{otherFile.errors}
现在似乎不起作用,它只假设第一个对象(文件)您的问题是
ng repeat end
不接受参数。
如果您想对上述不同对象执行ng repeat
,则需要启动一个新的ng repeat
块
编辑:添加包装html以显示点。你可能想改变一下
<div ng-repeat="file in files track by $index">
<tr>
<td class="name-col">{{file.name}}<br>
</td>
<td class="name-col">{{file.progress}}</td>
</tr>
<tr>
<td colspan="2">
{{otherFile[$index].errors}}
</td>
</tr>
</div>
{{file.name}}
{{file.progress}
{{otherFile[$index].errors}
也许这样可以:
<tr ng-repeat-start="file in files">
<td class="name-col">{{file.name}}<br>
</td>
<td class="name-col">{{file.progress}}</td>
</tr>
<tr ng-repeat-end>
<td colspan="2">
{{otherFiles[ $index ].errors}}
</td>
</tr>
{{file.name}}
{{file.progress}
{{otherFiles[$index].errors}
在这种情况下,otherFile如何知道迭代其他文件?你必须在处理html的方式上有所创新,但看看我对我的帖子所做的编辑,我想你能理解要点。@jeremy,它不起作用了?或者这不是你想要的方式?