AngularJS对表和行跨重复 [英] AngularJS repeat with table and rowspan
本文介绍了AngularJS对表和行跨重复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
说我具有以下数据结构
* Key 1
* Value 1
* Value 2
* Key 2
* Value 3
* Value 4
* Value 5
如何使用AngularJS在类似于以下的表格中呈现它:
How, with AngularJS, can I render it in a table similar to the following:
|-------|---------|
| Key 1 | Value 1 |
| |---------|
| | Value 2 |
|-------|---------|
| Key 2 | Value 3 |
| |---------|
| | Value 4 |
| |---------|
| | Value 5 |
|-------|---------|
按键通过rowspan
完成.
推荐答案
好而棘手的问题!
一种方法是:
给出这样的对象:
$scope.testData={
key1:[1,2],
key2:[3,4,5]
};
您可以这样做:
<table>
<tr ng-repeat-start="(key, val) in testData">
<td rowspan="{{val.length}}">{{key}}</td>
<td>{{val[0]}}</td>
</tr>
<tr ng-repeat-end ng-repeat="value in val.slice(1)">
<td>{{value}}</td>
</tr>
</table>
这篇关于AngularJS对表和行跨重复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文