Set number slide in slidebox


#1

I using ionic and when i want start slide 1 running app.i don’t want start 0,so What do I have to start running first slide 1


#2

http://ionicframework.com/docs/api/directive/ionSlideBox/

Use the active-slide attribute.

<ion-slide-box active-slide="1">
  <ion-slide>
    <div class="box blue"><h1>BLUE</h1></div>
  </ion-slide>
  <ion-slide>
    <div class="box yellow"><h1>YELLOW</h1></div>
  </ion-slide>
  <ion-slide>
    <div class="box pink"><h1>PINK</h1></div>
  </ion-slide>
</ion-slide-box>

#4

but : Expression ‘1’ used with directive ‘ionSlideBox’ is non-assignable!

 <ion-slide-box active-slide="1" show-pager="false">
 <ion-slide>
    <div class="box blue"><h1>BLUE</h1></div>
  </ion-slide>
  <ion-slide>
    <div class="box yellow"><h1>YELLOW</h1></div>
  </ion-slide>
  <ion-slide>
    <div class="box pink"><h1>PINK</h1></div>
  </ion-slide>
</ion-slide-box>

help me!


#5

You can use the $ionicSlideBoxDelegate to assign the active slide
http://ionicframework.com/docs/api/service/$ionicSlideBoxDelegate/


#6

That was my problem. The active-slide attribute, requires an expression. So, you need to set a model in the controller to use it.

<ion-slide-box active-slide="myActiveSlide">
$scope.myActiveSlide = 1;

Sample : http://codepen.io/calendee/pen/Kbpyg