I'm developing a dashboard where each user can visualize his "workspace" and "projects" (a workspace can have multiple projects). To do that I've created two mat-cards combined with ngFor in this way:
<mat-card id="ws.id" *ngFor="let ws of workspace; let i = index">
<mat-card-header class="app">
<div class="column1">
<mat-card-title>WorkSpace: {{ws.name}}
<button mat-icon-button [matMenuTriggerFor]="menu">
<mat-icon>more_vert</mat-icon>
</button>
...
</mat-card-title>
</div>
<div class="column2">
...
</div>
</mat-card-header>
<mat-card-content [style.overflow]="'auto'" [style.height.px]="'280'">
<div class="content" style="width: 95%;">
<div id="ws.name" fxLayout="row wrap" style="align-self: flex-start;" fxLayoutGap="16px grid">
<div id="ws.id" style="align-self: flex-start;" fxFlex="25%" fxFlex.xs="100%" fxFlex.sm="33%" *ngFor="let project of projects; let i = index">
<mat-card id="projects" class="mat-elevation-z4" *ngIf="ws.id === project.ws_id">
<mat-card-header id="{{project.id}}" class="app">
<div class="column1">
<mat-card-title>{{project.title}}</mat-card-title>
</div>
<div class="column2">
xxx
</div>
</mat-card-header>
<mat-card-content [routerLink]="['/projects/', project.ws_id, project.id]" style="text-align: center;">
...
</mat-card-content>
</mat-card>
</div>
</div>
</div>
</mat-card-content>
</mat-card>
The second workspace card starts with a number of empty project cards equal to the number of projects on the first card. In the attached image I have 7 projects on the first workspace and as can be seen, the projects on the second workspace start from the 8th "position" with 7 empty cards first.
Is there a way to reset the index of the second workspace card? is it the correct approach?