AngularJS重复表和rowspan
发布时间:2020-12-17 07:42:43 所属栏目:安全 来源:网络整理
导读:说我有以下数据结构 * Key 1 * Value 1 * Value 2* Key 2 * Value 3 * Value 4 * Value 5 如何使用AngularJS,可以将其呈现在类似于以下内容的表格中: |-------|---------|| Key 1 | Value 1 || |---------|| | Value 2 ||-------|---------|| Key 2 | Value
说我有以下数据结构
* Key 1 * Value 1 * Value 2 * Key 2 * Value 3 * Value 4 * Value 5 如何使用AngularJS,可以将其呈现在类似于以下内容的表格中: |-------|---------| | 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> Example (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |