UniSound Waterloo
UniSound Waterloo

Reputation: 561

Cannot get slidesCount from $ionicSlideBoxDelegate

I am creating a mobile app with Ionic framework. I am using ion-slide-box

        <ion-slide-box class="slidebox" on-slide-changed="change(index)"> 
              <ion-slide>
                  <img src="img/johnson.jpg" id="album">
              </ion-slide>
              <ion-slide>
                  <img src="img/eiston.jpg" id="album">
              </ion-slide>
              <ion-slide>
                  <img src="img/vera.jpg" id="album">
              </ion-slide>
              <ion-slide>
                  <img src="img/max.jpg" id="album">
              </ion-slide>
        </ion-slide-box>

I want to know the total slide number

$scope.change= function(index){
    console.log('currentindex '+index);      //i get the correct current index
    console.log($ionicSlideBoxDelegate.currentIndex());   //I get undefined
    alert($ionicSlideBoxDelegate.slidesCount());     //I get undefined
} 

I tried a lot of things, nothing seems to be working with $ionicSlideBoxDelegate? Is it deprecated?

Upvotes: 0

Views: 532

Answers (2)

Dz_Hero
Dz_Hero

Reputation: 41

You should use <ion-slides> instead of <ion-slide-box>, then try to add a modal to slider param i.e:

<ion-slides  options="options" slider="data.slider">
    <ion-slide-page>
      <div><h1>some Text</h1></div>
    </ion-slide-page>
</ion-slides>

then in your controller you will use 'data.activeIndex' to get the current index using a handler as:

$scope.$on("$ionicSlides.slideChangeEnd", function(event, data){
   alert( data.activeIndex );
});

you can consult the doc: http://ionicframework.com/docs/api/directive/ionSlides/

Upvotes: 1

t0mm13b
t0mm13b

Reputation: 34592

Ionic's new slide is derived from swiper.

According to ionic's documentation it is deprecated in favour of the newer component.

You will have to do a bit of research into how to use the newer component as it is not documented very well.

Upvotes: 0

Related Questions