As I cycle through a list of products, I am verifying if the product Id is already included in an array of products (objects). If it is, then I print the quantity. If not, I attempt to print 0. Here is the code snippet I have been working on:
<ion-item class="added" *ngFor="let item of fetchProducts(); let key=index;">
<ng-container *ngFor="let cartitem of cart">
<span class="count" *ngIf="cartitem.p_id == item.p_id;">
{{ cartitem.qty }}
</span>
<span class="count" *ngIf="cartitem.p_id !== item.p_id">
0
</span>
</ng-container>
</ion-item>
I am looking for a way to display 0 if item
is not found within the cartitem
.