Grab reference to Slides in ionic2

I am not being able to get a reference to the Slides in ionic2.

<ion-slides #slides [options]="mySlideOptions" (ionDidChange)="onSlideChanged()" >
{
   @ViewChild('slides') slider: Slides;
 console.log(this.slider.getActivityIndex()); returns error undefined!

Please tell me how can I get a reference to my slides.

Where are you placing this log?

If the view hasn’t be fully rendered out, the ViewChild can’t get a reference. So it will return undefined.

Place this call in an ionViewDidEnter

export class MyClass{

---
   ionViewDidEnter(){
     console.log(this.slider.getActivityIndex());
  }
}