Slider initialSlide option not working

I’ve been using the ion-slides component for several view in my app. Some of these sliders should be kept in sync when navigating through the views. When I go from one page with a slider to a different one I pass the current index of the slider to the new view. In the constructor of that new view I set the options for the new slider. One of the options is initialSlide which gets set to the value from the index of the slider on the previous page. Sometimes this works but others it doesn’t.

In the first view:

this.navCtrl.setRoot(OverviewPage, { page: this, index: this.slider.getActiveIndex() }, { animate: true, animation: ‘md-transition’ })

in the second one:

constructor(navParams: NavParams) {
var index = this.navParams.get(‘index’);

  this.title = this.slides[index].title;
  this.sliderOptions = {
      initialSlide: index,
      direction: 'horizontal'
  };

}

1 Like