0

I have a list of image they come from an json array with 7 elements : The key of image is

 <ion-grid>
    <ion-row    *ngFor="let image of imageList; let i = index;">
      <ion-col>
           <div >
 
            <img  [src]="image.imageUrl"  />
         </div>      </ion-col>
      <ion-col>
          <div  >
            <img  [src]="image.imageUrl"  />
        
          </div>
      </ion-col>
    </ion-row>
 
    </ion-grid>

But this code show me the same pic per row , I have tried to set image[i] on the first col and image[i+1] on the second but nothing.

I want to show two image per row like this but without same image.

Thanks.

DEVLOGIN
  • 87
  • 1
  • 9

1 Answers1

0

Something like this should work:

<ion-grid>
 <ion-row    *ngFor="let image of imageList; let i = index;">
  <ion-col>
       <div >
        <img  [src]="imageList[i]?.imageUrl"  />
     </div>      </ion-col>
  <ion-col>
      <div  >
        <img  [src]="imageList[i + 1]?.imageUrl"  />
      </div>
  </ion-col>
</ion-row>

Inside de *ngFor loop, the image will always be one image for every iteration. You should iterate the imageList and use the index to access the images from imageList. Hope it makes sense

Callan
  • 1,179
  • 1
  • 7
  • 18