如何在AngularJS中循环多个Table TH [英] How to loop multiple Table TH in AngularJS
本文介绍了如何在AngularJS中循环多个Table TH的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<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>
是否可以根据$ctrl.otherdata
的长度在ng-repeat中的第3个循环?
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>
我尝试过,但是看起来违反了网络标准,我尝试使用DIV,但是看起来无法在表格中使用,所以还有其他选择吗?
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 ?
检查附件图像:这就是我在寻找使用角度js的抛出循环
Check attached image : this is what i am looking for throw loop using angular js
推荐答案
这应该有效-
<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>
这篇关于如何在AngularJS中循环多个Table TH的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文