简体   繁体   中英

ionic framework slides component "loop" option

I am currently developing an application using Ionic-Angular. for slides I am using ionic 4 ion-slides component and every thing works fine but I was looking for a way to loop the slides so that user can have swipe with no locking at the end of array according to ionic docs => ion-slides

and Swiper API

I can achieve this by using loop property in options, so I followed the instruction but it doesn't seem to work and the slide locks at the end of the array My HtMl code is:

<ion-slides #theSlides [options]="slideOpts"   id="peerSlide">
    <ion-slide *ngFor="let peer of peers;let i = index">
       <img id="{{'x' + i}}" class="peerIcon" [src]="peer.icon" >
     </ion-slide>
</ion-slides>
<img class="nextIcon" src="../../assets/imgs/nextIcon/nextIcon@3x.png" (click)="moveToNext(theSlides)">
<img class="prevIcon" src="../../assets/imgs/prevIcon/prevIcon@3x.png" (click)="moveToPrev(theSlides)">

and my.ts file:

export class LivePage implements OnInit {
  @ViewChild('theSlides' , {  static: true }) slides: IonSlides;
 
  slideOpts = {
  loop: true,
   };

  ...
  moveToNext(slides) {
   slides.slideNext()
  }
  moveToPrev(slides) {
   slides.slidePrev()
  }
 }

I appreciate if you can tell what is wrong here with my code thank you.

Update: when i try it with out ngFor the loop will work fine but with ngFor it doesn't

It's worked for me with same code ("@ionic/angular": "^5.0.0") try to update your dependancies

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM