Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Json返回对象(离子型)(Angularjs)问题_Angularjs_Json_Ionic Framework - Fatal编程技术网

Json返回对象(离子型)(Angularjs)问题

Json返回对象(离子型)(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

我试图迭代所有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-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>