1

I am using ion-Slides to show the selected image from the gallery and swipe them horizontally and it is working good but I want to show the last selected image on the screen.

I tried using slideTo() and it causing the type error.

For more clarity: I am running a loop where I push selected images from gallery in with base64 conversion into an array and pass it in an image tag to show images on the HTML screen.

any help would be great.

Ragesh Pikalmunde
  • 1,333
  • 1
  • 20
  • 44

2 Answers2

2

@ViewChild('slides', { static: false }) slider: IonSlides; I faced a similar problem. Had to change static from true to false.

Mr. Disability
  • 799
  • 1
  • 10
  • 19
0

You can use ionSlidesDidLoad event to make sure ion-slide has loaded.

subscribe for the event in your html file like following sample:

<ion-content>
  <ion-slides  (ionSlidesDidLoad)="slidesLoaded($event)">
    <ion-slide>
      <h1>Slide 1</h1>
    </ion-slide>
    <ion-slide>
      <h1>Slide 2</h1>
    </ion-slide>
  </ion-slides>
</ion-content>

and in your ts file add the following method:

    public slidesLoaded($event) {
    //move to slide number 2
    $event.target.slideTo(2);
    }

This event is available in Ionic 4 and later.

Ghonche Yqr
  • 305
  • 1
  • 10