Berry Tsakala
Berry Tsakala

Reputation: 16600

angularJS add table row (TR) inside an ng-repeat -

EDIT this is a similar (or duplicate) of Angular.js ng-repeat across multiple elements

-

i have a table, whose rows are generated via ng-repeat:

<tr ng-repeat="(key, value) in rows"> 
    <td>{{a}}</td>
    <td>{{b}}</td>
</tr>

i'd really prefer to keep it in <table> tag, and not several inline-blocks, for various reasons.

How can I add another row just below each row, e.g. pseudo-code

[ somehow-repeat ng-repeat="(key, value) in rows"]
    <tr class="1"> 
        <td>{{a}}</td>
        <td>{{b}}</td>
    </tr>

    <tr class="1"> 
        <td colspan="2">
    </tr>
[ /somehow-repeat ]

as far as i know (worth checking) i can't wrap the TR inside another element. just chekced :( the table doesn't show if i the "somehow-repeat" element is or

so - is there a way to add new row despite being in ng-repeat?

Upvotes: 4

Views: 4105

Answers (1)

Ye Liu
Ye Liu

Reputation: 8976

You can use repeat-start and repeat-end:

<tr class="1" ng-repeat-start="(key, value) in rows"> 
    <td>{{a}}</td>
    <td>{{b}}</td>
</tr>

<tr class="1" ng-repeat-end> 
    <td colspan="2">
</tr>

Upvotes: 7

Related Questions