Json返回对象(离子型)(Angularjs)问题
我试图迭代所有json文件,它使用{{title}}并显示所有内容,但不使用附件url Json htmlJson返回对象(离子型)(Angularjs)问题,angularjs,json,ionic-framework,Angularjs,Json,Ionic Framework,我试图迭代所有json文件,它使用{{title}}并显示所有内容,但不使用附件url Json html <ion-content> <ion-card *ngFor="let user of users"> <img [src]="user.attachments.url"> <!--It doesn't work--> <ion-card-content> <ion-card
<ion-content>
<ion-card *ngFor="let user of users">
<img [src]="user.attachments.url"> <!--It doesn't work-->
<ion-card-content>
<ion-card-title>
{{ user.title }} <!--WORK-->
</ion-card-title>
</ion-content>
附件是一个数组,所以您只能像这样使用它,可能的解决方案是
<ion-content>
<ion-card *ngFor="let user of users">
<img [src]="user.attachments[0].url"> <!--first attachment. It will give error for no attachments-->
<ion-card-content>
<ion-card-title>
{{ user.title }} <!--WORK-->
</ion-card-title>
{{user.title}}
你好!,谢谢你的时间来评论,我也尝试过这种方式,只显示了20个结果中的6个,其余14个结果返回为空白,没有标题和图像
<ion-content>
<ion-card *ngFor="let user of users">
<img [src]="user.attachments[0].url"> <!--first attachment. It will give error for no attachments-->
<ion-card-content>
<ion-card-title>
{{ user.title }} <!--WORK-->
</ion-card-title>