Angular 使用json响应生成动态列表
我有一个json数组,如下所示Angular 使用json响应生成动态列表,angular,typescript,ionic-framework,ionic2,Angular,Typescript,Ionic Framework,Ionic2,我有一个json数组,如下所示 "collectings": [ { "hint": "OPEN", "amount": 24 }, { "hint": "CREDIT CARD", "amount": 347 }, { "hint": "CASH", "amount": 256.5 } ] <ion-content> <div class="row"
"collectings": [
{
"hint": "OPEN",
"amount": 24
},
{
"hint": "CREDIT CARD",
"amount": 347
},
{
"hint": "CASH",
"amount": 256.5
}
]
<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>
现在,我想在一个列表上动态显示这些数据,我试着像下面这样做
"collectings": [
{
"hint": "OPEN",
"amount": 24
},
{
"hint": "CREDIT CARD",
"amount": 347
},
{
"hint": "CASH",
"amount": 256.5
}
]
<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>
喜剧片
{{collections}}
但是,它显示在页面上,如下图所示;
如何正确显示它?而不是
{{collections}
(数组)
@sebaferreas我已经试过了,但是,当我这么做的时候,它什么也没有显示。我已经用ngIf部件检查了数组是否为空,因为我从rest获取数组作为响应,并将其绑定到我的数组。@sebaferreas是的,你是对的。我正在印刷收藏品。现在,它起作用了