我得到具有列和行如下如何使用单纳克重复
$scope.table = {
Columns: [{Header:"22-Jul-15",SubHeaders: ["10:33 AM"]}
, {Header:"21-Jul-15",SubHeaders: ["03:40 AM"]}
, {Header:"17-Jul-15",SubHeaders: ["01:05 PM", "12:06 PM"]}]
, Rows:[{Items:[{Value:1},{Value:5},{Value:8},{Value:""}]}
,{Items:[{Value:2},{Value:6},{Value:9},{Value:""}]}
,{Items:[{Value:3},{Value:7},{Value:10},{Value:15}]}]
} //end of table
我想显示Columns.SubHeaders
作为表的子标题行表的JSON使用纳克重复用于阵列中的阵列。
这里是我的尝试,但没有奏效
<table class="table table-stripped table-bordered">
<thead>
<tr>
<th ng-repeat="col in table.Columns" colspan="{{col.SubHeaders.length}}">{{col.Header}}</th>
</tr>
<tr>
<td class="center text-black" ng-repeat="head in table.Columns[0].SubHeaders">{{head}}</td>
</tr>
</thead>
<tbody>
<tr ng-repeat="row in table.Rows">
<td ng-repeat="item in row.Items">
{{item.Value}}
</td>
</tr>
</tbody>
</table>
我以前head in table.Columns[0].SubHeaders
只是为了显示它正在为硬编码的索引值。
如何使用单个ng-repeat来实现这一点?我可以使用两个ng-repeats,但它会导致不必要的html标记。
是的,该标记不起作用...有一件事,您的表格数据(每个项目3列)不匹配列布局(4列将副标题作为实际列)。你打算如何匹配他们? –
是的,我创建它用于演示目的。我在我的实际数据中有适当的列 – kiran
我已更新可以检查https://jsfiddle.net/je7dvu1o/17/ –