Valery
Valery

Reputation: 755

Angular, ng-repeat and rowspan on the same td

Given this data:

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

How does one generate the following with 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>

Upvotes: 1

Views: 561

Answers (1)

gtlambert
gtlambert

Reputation: 11961

You could use the following:

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

Upvotes: 2

Related Questions