I’m using Ionic 2 / Angular, but I realized that the ngFor function can’t read objects. Also, I need it to be shown only if the cart
is not empty.
Object:
{
"48131": {
"code":"D40905",
"name":"ДАМСКА ПЛЕТЕНА БЛУЗА КЪС РЪКАВ ЩАМПА REASON",
"price":"18.99",
"size":"STANDART",
"qty":"1"
},
"49410": {
"code":"D41821",
"name":"ДАМСКА БЛУЗА ТРИКО",
"price":"44.99",
"size":"M",
"qty":"4"
}
}
HTML:
<ion-row *ngFor="let p of cart">
<ion-col col-3>
<div><img src="http://example.com/products/small/{{p.code}}-1.jpg" /></div>
</ion-col>
<ion-col col-9>
<ion-row>
<ion-col col-12>
<div>{{p.name}}</div>
</ion-col>
</ion-row>
<ion-row>
<ion-col col-12>
<div>{{p.qty}} бр ({{p.size}} размер) x <b>{{p.price}} лв</b></div>
</ion-col>
</ion-row>
<ion-row>
<ion-col col-12>
<div (click)="deleteCart({{p.id}})">Изтрий <ion-icon name='trash' item-start color="danger"></ion-icon></div>
</ion-col>
</ion-row>
</ion-col>
</ion-row>
Can someone help me with this? I’ve tried so many things…