Swiper Element (WebComponent) - how to use slideTo

Discussão em 'Angular' iniciado por MadMac, Fevereiro 19, 2025.

  1. MadMac

    MadMac Guest

    I have updated my angular version from 12 to 16 for my Ionic project and have had to update the slider component.

    I am using the Swiper Element (WebComponent) v11.2.4 https://swiperjs.com/element and I need to programmatically move to a slide the same way I was with the older swiper. Previously I was using

    this.swiper.setIndex(arrayIndex)


    I have tried the below but it does not work. Any suggestions?

    @ViewChild('swiperContainer', { static: false }) swiperContainer: ElementRef;

    this.swiperContainer.nativeElement.slideTo(arrayIndex, 0, false);


    Update

    I got it working using:

    this.swiperContainer.nativeElement.swiper.slideTo(arrayIndex, 0, false);


    But curious if there is a better way.

    Continue reading...

Compartilhe esta Página