Issue with ion-Slides swipe


I want to disable swipes on my ion-slides.


    <h1>Slide 1</h1>
    <h1>Slide 2</h1>
    <h1>Slide 3</h1>



@ViewChild(Slides) slides: Slides;


  constructor(public navCtrl: NavController, public navParams: NavParams) {

But this gives a lot of errors…can anyone tell what may be the issue?

Uncaught (in promise): TypeError: Cannot read property ‘lockSwipes’ of undefined
TypeError: Cannot read property ‘lockSwipes’ of undefined
at new QuestionDetails…


Very much likely because you’re callingthis.slides.lockSwipes(true) from within your constructor. I guess the slides aren’t initalized at that moment yet, so the ViewChild is undefined at that moment in time.

Try running this.slides.lockSwipes(true) after your view has rendered, i.e. wrap it inside ionViewDidLoad() { this.slides.lockSwipes(true) } and place it outside your constructor.


Thanks man…!! :smile:
Works like charm