Revamp the structure of the array being utilized in the component by converting it into an array of arrays, each containing 4 elements.
let items = [ [1, 2, 3, 4], [5,6,7,8] ];
Below is an illustration of how you can restructure the array using a loop:
const items = [1, 2, 3, 4, 5, 6, 7, 8];
const parentArray = [];
let childArray = [];
items.forEach(item => {
childArray.push(item);
if(childArray.length === 4){
parentArray.push(childArray);
childArray = [];
}
});
Subsequently, embed another ‘ngFor’ within the first one in your template:
<div *ngFor=“let item of parentArray”>
<div *ngFor=“let subItem of item>
{{ subItem }}
</div>
</div>
Although not the most elegant solution, this method aligns with your request.