Reputation: 249
I have a json array like following;
"collectings": [
{
"hint": "OPEN",
"amount": 24
},
{
"hint": "CREDIT CARD",
"amount": 347
},
{
"hint": "CASH",
"amount": 256.5
}
]
Now, I want to display this data on a list dynamically, I am trying to do it like following;
<ion-content>
<div class="row" *ngIf="collectings && collectings.length > 0">
<ion-list>
<ion-list-header>Comedy</ion-list-header>
<ion-item *ngFor="let collecting of collectings">{{collectings}}</ion-item>
</ion-list>
</div>
</ion-content>
but, it is displayed on the page like the below image;
How can I display it properly?
Upvotes: 5
Views: 2414
Reputation: 44659
Instead of {{ collectings }}
(which is the array)
<ion-item *ngFor="let collecting of collectings">{{collectings}}</ion-item>
you should print the collecting
property (without the ending s) and use the hint
or amount
sub-properties like this:
<ion-item *ngFor="let collecting of collectings">
{{collecting.hint}} - {{ collecting.amount }}
</ion-item>
Upvotes: 3