ps0604
ps0604

Reputation: 1071

Angular repetition of two rows instead of single row

I need to have an *ngFor of table rows, where each repetition consists in 2 rows, as shown here.

But in Angular the repetition is done for each row, not each 2:

<table>
   <tr *ngFor="let row of rows; let i = index">
       <td>{{row.somethingA}}</td>
       <td>{{row.somethingB}}</td>
   </tr> 
</table>

What is the best way to approach this?

Upvotes: 2

Views: 260

Answers (1)

mbojko
mbojko

Reputation: 14679

You can always use an ng-container.

<ng-container *ngFor="let row of rows; let i = index">
    <tr>{{ row.something }}</tr> 
    <tr>{{ row.somethingElse }}</tr> 
</ng-container>

Upvotes: 5

Related Questions