My goal is to copy this behaviour and to include it in a ngFor loop.
I've tried several codes, each one having a different issue:
Try 1:
<table class="table">
<tbody>
<tr *ngFor="let game of games; let i = index" class="clickable-row" data-toggle="collapse" [attr.data-target]="'#gameDetails' + i">
<td class="text-nowrap">{{game.date}}
<div [attr.id]="'gameDetails' + i" class="collapse">
<p>Insert a large component in this place</p>
</div>
</td>
<td class="text-nowrap">{{game.label}}</td>
<td class="text-nowrap">{{game.score}}</td>
</tr>
</tbody>
</table>
Try 1 result, collapsed:
Try 1 result, deployed:
In the try 1 the problem is that the collapsed component fits in the left cell, impacting the cells at his right.
Try 2:
<table class="table">
<tbody>
<div *ngFor="let game of games; let i = index">
<tr class="clickable-row" data-toggle="collapse" [attr.data-target]="'#game2Details' + i">
<td class="text-nowrap">{{game.date}}</td>
<td class="text-nowrap">{{game.label}}</td>
<td class="text-nowrap">{{game.score}}</td>
</tr>
<tr [attr.id]="'game2Details' + i" class="collapse">
<td colspan="3">Insert a large component in this place</td>
</tr>
</div>
</tbody>
</table>
Try 2 result, collapsed:
Try 2 result, deployed:
In the try 2 we lose the table indentation when details are collapsed.
Try 3:
<table class="table">
<tbody>
<tr *ngFor="let game of games; let i = index">
<table class="table">
<tbody>
<tr class="accordion-toggle" data-toggle="collapse" [attr.data-target]="'#game4Details' + i">
<td>{{game.date}}</td>
<td>{{game.label}}</td>
<td>{{game.score}}</td>
</tr>
<tr>
<td colspan="3" class="hiddentablerow">
<div [attr.id]="'game4Details' + i" class="accordian-body collapse">Insert a large component in this place
</div>
</td>
</tr>
</tbody>
</table>
</tr>
</tbody>
</table>
Try 3 result, collapsed:
Try 3 result, deployed:
In the try 3 the indentation differs between the different inner tables.
Is there a way to keep the indentation before and after the deploy of the collapsed row? Or maybe another way using something else than a table ?





