Avinash Jagtap
Avinash Jagtap

Reputation: 111

ion slider not working in ModalController ionic 4

Version: Cordova: [email protected] Ionic: 6.10.1

Error : this.slider.update is not a function

in .ts

import { ModalController, IonSlides } from "@ionic/angular";

 trainingSliderOpts = {
speed: 400,
initialSlide: 0,
preloadImages: true,
allowTouchMove: false,
 };
result: any;
@ViewChild("trainingSlider", { static: true }) slider: IonSlides;

  ionViewDidEnter() {
this.slider.update();
}

Upvotes: 1

Views: 374

Answers (1)

Mike Leins
Mike Leins

Reputation: 52

Try to add a .then function at the end like that:

this.ionSlides.update().then(() =>
        console.log('updated'))
    }

If not working try the following on top of your your class:

 @ViewChild('slider', {read: ElementRef})slider: ElementRef;

and then call it like this:

this.slider.nativeElement.update();

Upvotes: 1

Related Questions