Getting Swiper Instance

Is there a way to get the Swiper instance for an <ionic-slides> element? The swiper documentation says you can search the page for the element with the ‘swiper-container’ class but I was wondering if there was a more idiomatic way that doesn’t involve accessing the DOM manually?

So you could do this

Where you pass a local variable and then use that with the options property

1 Like

Ah, that’s a good catch that the Swiper api passes an instance of itself to the initialization method! It’s certainly better than what I was doing before though it’s also not quite as idiomatic as I had hoped. Is this going to be available through regular dependency injection? Or is there some other way to get references to objects representing components in a page?

Hi,
I was doing line
this.mySlideOptions = {
pager: true,
onInit: function(slides: any) {
console.log("init slide " + slides)
},
onSlideChangeStart(slides: any) {
console.log("onSlideChangeStart " + typeof slides.activeIndex)
setTimeout(() => {
this.kanbanSlideTitle = this.num_slide[slides.activeIndex][‘task_status_name’];
}, 500)

    },
    onSlideChangeEnd(slides: any) {
        console.log("onSlideChangeEnd " + slides.activeIndex)
    }
};

but it will not be able to call onSlideChangeEnd or onward if defined.
May i know why ?

Please let us know.

Thanks
Shivam