Search code examples
angularimagecountngforswiper.js

ngFor - Display 3 Images of Array in 1 Swipe before next "swiperSlide" starts


I have a swiper with images in the array "ktv", but I want to display 3 images one below the other, before the next "swiperSlide" begins. Any solutions for this ngFor?

<swiper [config]="pageKtvSlideOpts" #swiper>
  <ng-template *ngFor="let k of ktv" swiperSlide>
    <img [src]="k.img">
  </ng-template>
</swiper>

Solution

  • Thank you. This solution with ngFor & ngIf solved my problem:

    <swiper [config]="pageKtvSlideOpts" #swiper>
      <ng-container *ngFor="let k of ktv; let ind = index;">
        <ng-template *ngIf="ind % 3 == 0" swiperSlide>
          <ng-container>
            <img [src]="ktv[ind].img">
            <img [src]="ktv[ind+1].img">
            <img [src]="ktv[ind+2].img">
          </ng-container>
        </ng-template>
      </ng-container>
    </swiper>