如果我有以下数据结构:
data = [{"nums": [1, 6, 5], "name": "John"},
{"nums": [2], "name": "Bob"},
{"nums": [9, 6], "name": "Jason"}]
我希望它使用 ng-repeat 输出为 html:
|------------|
| 1 | |
|---| |
| 6 | John |
|---| |
| 5 | |
|---|--------|
| 2 | Bob |
|---|--------|
| 5 | |
|---| Jason |
| 2 | |
|---|--------|
我该怎么做?
最佳答案
您可以在 tbody 上使用 ng-repeat,然后像这样继续向下循环
<table>
<tbody ng-repeat="row in data">
<tr ng-repeat="col in row.nums">
<td>{{col}}</td>
<td rowspan="{{$first ? row.nums.length : 1}}" ng-show="$first">{{row.name}}</td>
</tr>
</tbody>
</table>
Se plunker here
关于javascript - AngularJS 使用 RowSpan 在表中生成分组数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42165096/