IONIC 4 : getActiveIndex() is not working in ion-slides

Using Slides Instead of Slide

@Cambodia - don’t really see how your comment should help anyone. Maybe you could elaborate your answer a bit? :yum:

@sibrannstrom - have you found a solution to your problem? I am creating IonSlide elements too with an *ngFor and then pushing onto the array and then I update the slider with the update method. when calling getActiveIndex afterwards in some cases it returns the correct index, in other ones it doesn’t return anything. Has anyone faced a similar issue?

edit: i set up the slider as child component in a page. when I first load the page, it works fine but after navigating back into this page from my overview page for the second time, it does not return anything anymore for the getActiveIndex method. Do I need to reset the ViewChild (if it’s even possible)?

HTML

<ion-slides pager="true" #slider (ionSlideWillChange) ="MethodHere()">
      <ion-slide>
        <h1>Slide 1</h1>
      </ion-slide>
      <ion-slide>
        <h1>Slide 2</h1>
      </ion-slide>
      <ion-slide>
        <h1>Slide 3</h1>
      </ion-slide>
    </ion-slides>

file.ts

@ViewChild('slider', { static: true }) slidefromHtml: IonSlides; /// use  **IonSlides** instead of IonSlide

MethodHere() {
    slides.getActiveIndex().then(id => {
         consol.log('your index', id)
      }
    });
  }

Hope can help thanks.