Ionic 2 RC5+ Advanced Slides

Hello!
I’m trying to finish migrating from Ionic2 RC4 to Ionic 2.0.0 and experience troubles with slides. There’s not much in docs about how to implement advanced slides, but it seems like I’ve done everything right and it gives me an error.

My specs:

Ionic Framework: 2.0.0
Ionic Native: 2.4.1
Ionic App Scripts: 1.0.0
Angular Core: 2.2.1
Angular Compiler CLI: 2.2.1
Node: 7.0.0
OS Platform: macOS Sierra
Navigator Platform: MacIntel
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.95 Safari/537.36

My HTML:

<ion-slides #slider (ionSlideDidChange)="onSlideChanged()">
  <ion-slide *ngFor="let sub of subcategoriesArray">
    {{ sub.name }}
  </ion-slide>
</ion-slides>
<ion-slides #subSlider (ionSlideDidChange)="onSubSlideChanged()" class="services-slider">
  <ion-slide *ngFor="let sub of subcategoriesArray">
    <ion-col *ngFor="let service of sub.services">
      <ion-item (click)="goToService(service)">
        {{service}}
      </ion-item>
    </ion-col>
  </ion-slide>
</ion-slides>

My TS:

@ViewChild(‘slider’) slider: Slides;
@ViewChild(‘subSlider’) subSlider: Slides;

ngAfterViewInit() {
// Slider options
this.slider.freeMode = false;
this.slider.freeModeMomentumBounce = false;
this.slider.slideToClickedSlide = true;
this.slider.centeredSlides = true;
}

The first line in ngAfterViewInit hook gives an error:
Error in :0:0 caused by: Cannot set property ‘freeMode’ of undefined

If you have any ideas what am I doing wrong, please share with me.
Thank you!

1 Like

Did you find a solution for this?

It doesn’t seem to be the best thing to do, but wrapping the code in setTimeout helped