I have an array containing a total of n items. My goal is to group every 6 items into separate div elements. However, if the array has 15 items, I struggle to group the last three remaining items.
Although the following code successfully groups every 6 elements, it does not handle the last 3 remaining items:
<ng-container *ngFor="let item of mockData; let i = index;">
<div class="inner-wrap" *ngIf="(i+1) % 6 ==0">
<p *ngIf="mockData[i-5]">{{ mockData[i-5] }}</p>
<p *ngIf="mockData[i-4]">{{ mockData[i-4] }}</p>
<p *ngIf="mockData[i-3]">{{ mockData[i-3] }}</p>
<p *ngIf="mockData[i-2]">{{ mockData[i-2] }}</p>
<p *ngIf="mockData[i-1]">{{ mockData[i-1] }}</p>
<p>{{ item }} </p>
</div>
</ng-container>