Ion-slides: Programmatically set and animate to a specific slide?

Hey guys, I’m wondering if there is a way to programmatically set and animate to a specific slide using the ion-slides component?

1 Like

Sorry I did originally reply to this before realising you were asking in relation to Ionic 2! So I am now wondering the same.

The demo source here : shows how to define an ion-slides container via the HTML template, how do I programatically reference said ion-slides container? Can I use something similar to ng-model (#mySlides) ?

Having spoken with Mike and rajkiran on Slack, here’s a fully working version!


import {Page, IonicApp, Slides} from 'ionic-angular';
import {ViewChild} from 'angular2/core';

	template: `
  <ion-navbar *navbar>
  <ion-title>Tab 1</ion-title>
  	<button (click)="goto(2)">Slide 2</button>

<ion-content padding class="page1">
  <ion-slides [options]="options" #slides>
      <img src="" alt="">
      <img src="" alt="">
      <img src="" alt="">


export class Page1 {
	public options: any = {
        onInit: (slides: any) => { this.swiper = slides; }
    swiper: any;
	constructor() {
	goto(slideNumber) {
		this.swiper.slideTo(slideNumber, 2000);

I’m wondering a similar thing as i tried something like this a little while ago and it did not work

<ion-slider options="{autoplay: 1000}"></ion-slider

Thanks for the tip, this works great!