I have two tables in db, and from the apis, i'm creating loops:
<div *ngFor="let laptop of laptops">
some content
<!-- Producer / Name -->
<div *ngFor="let producer of producers">
<div class="title" *ngIf="producer.id === laptop.producerId>
{{producer.name}} {{laptop.model}}
</div>
</div>
</div>
I have 70 producer names and foreign key from laptops to producer table. My e.g. laptop has got producerId = 3 and i want to loop for each producers and display only this which meets the condition. It works but when i see DOM, it scares me. 70 divs! I've read this: *ngIf and *ngFor on same element causing error
and after this:
<ng-container *ngFor="let producer of producers>
<div class="title" *ngIf="producer.id === laptop.producerId>
{{producer.name}} {{laptop.model}}
</div>
</ng-container>
I have in DOM:
Is that correct result? Or is there any way to create only that div which meets the condition?