i have an array of objects composed of objects (id,image), and i also have several cards as result of my fetch to the backend. What im trying to do is on every card establish a carousel exclusively with the images that match with the id the card has in fact , lets say this is my array of images
arrayOfImages:[
{id: "1",image: "xxxxxxxxxx"},
{id: "1",image: "xxxxxxxxxx"},
{id: "2",image: "xxxxxxxxxx"},
{id: "2",image: "xxxxxxxxxx"},
{id: "1",image: "xxxxxxxxxx"},
{id: "2",image: "xxxxxxxxxx"}
]
Lets say then on my html tag in angular i trigger the html :
<div *ngFor="let post of allPortafolio;let i=index">
//NgFor that bring me all cards from back
//some code
<ngb-carousel>
//carousel specific for one card where in i want to loop over the array of images
<ng-template ngbSlide *ngFor="let image of arrayOfImages">
<img *ngIf="post.id===image.id;else alternative" [src]="image.image">
<ng-template #alternative>
<img " else src="../../../assets/white.jpg">
</ng-template>
</ng-template>
</ngb-carousel>
</div>
As you could see , had to use an else , using other fixed template while the loops keeps its course not matching the id conditions, but the aesthetic is horrible, cause seems like if the page where in constant fetch recharge , instead of having a smooth flow in the carousel.
But i was wondering if there was another alternative where i could witouth using an else could loop over that array of objects and asign to every card its respective images with the matching id's to the card in fact, thus then their respective carousels would flow perfect without interruptions