5
Hello, I have an array items:any[]
and I want to iterate in the view with the *ngfor
, however, I am using a template <carousel>
where for every item of that slide I call <carousel-item>
, Today my code follows this hierarchy:
<carousel>
<carousel-item>
<div *ngFor="let item of items">
{{item.nome}}
</div>
</carousel-item>
<carousel-item>
<!-- outro conteúdo -->
</carousel-item>
</carousel>
With this code I have the following result, note that item 5 ends up exceeding the div:
My doubt: I want every 4 elements of the items create a new template <carousel-item>
, in order to stay that way:
I wonder if you can solve my problem using only the iteration of *ngFor and some *ngIf or modifying something in the hierarchy, but I have no idea how to solve without harming the performance of the application.
Thanks in advance.
I had a similar problem but could only calling a function in
ngFor
which returns an array of arrays, with sub arrays with a maximum of 4 items, so I used two loops– Costamilam