Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

angularjs

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?

like image 891
Berry Tsakala Avatar asked Mar 21 '23 05:03

Berry Tsakala


1 Answers

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>
like image 93
Ye Liu Avatar answered Mar 28 '23 04:03

Ye Liu