相同td上的Angular,ng-repeat和rowspan

时间:2016-02-21 11:17:59

标签: angularjs angularjs-ng-repeat html-table ng-repeat

鉴于此数据:

this.stuff = [
    [{title: 'col1', rowspan: 1},{title: 'col2', rowspan: 2}],
    [{title: 'col3', rowspan: 1}]
];

如何使用ng-repeat生成以下内容:



<table border="1">
    <tr>
        <td rowspan="1">col1</td>
        <td rowspan="2">col2</td>
    </tr>
    <tr>
        <td rowspan="1">col3</td>
    </tr>
</table>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:2)

您可以使用以下内容:

<table border="1">
    <tr ng-repeat="item in stuff">
        <td ng-repeat="obj in item" rowspan="{{ obj.rowspan }}">{{ obj.title }}</td>
    </tr>
</table>