Reputation: 179
i have question about hybrid mobile used ionic-cordova-angular. this question about problem ionic-slide-box without button next. i try to get current index when user swift page in slidebox.
how to get current index without i create button next slide.
Upvotes: 1
Views: 10295
Reputation: 6245
Did you tried this?
function MyCtrl($scope, $ionicSlideBoxDelegate) {
$scope.getCurrentIndex = function() {
$ionicSlideBoxDelegate.currentIndex();
}
}
http://ionicframework.com/docs/api/service/$ionicSlideBoxDelegate/
UPDATE:
To get the box index without a button you could use the callback onSlideChange of ionSlideBox directive:
HTML:
<ion-slide-box on-slide-changed="slideHasChanged($index)">
<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>
Inside you controller:
$scope.slideHasChanged = function($index){
alert('slideHasChanged $index=' + $index);
if($index === 0){
// first box
}
};
Upvotes: 8