我得到具有列和行如下如何使用單納克重複
$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/ –