In ion mode, we have slideBox.I want to disable scrolling. I want it to slide at the click of a button. How can i do this?
I tried $ionicSlideBoxDelegate.enableSlide(false)in my controller, but it does not work.
$ionicSlideBoxDelegate.enableSlide(false)
According to this link http://forum.ionicframework.com/t/ionicslideboxdelegate-disable-all-swiping/6391 I need to disable in the slide area, but how to access the scope of the element and apply it?
The right place for this is ng-init
ng-init
<ion-slide-box ng-init="lockSlide()">
and have the appropriate function in your controller
.controller('sliders', function($scope, $ionicSlideBoxDelegate) { $scope.lockSlide = function () { $ionicSlideBoxDelegate.enableSlide( false ); } }
html active-slide = "slidestop ($ index)"
<ion-slide-box active-slide="slidestop($index)"> </ion-slide-box>
, slidestop
$scope.slidestop = function(index) { $ionicSlideBoxDelegate.enableSlide(false); }
Probably your problem is that the slider needs to be visualized before you can turn off the slide. So in your controller use a timeout:
$timeout(function(){ $ionicSlideBoxDelegate.enableSlide(0); },0);
In html add
<ion-slide-box active-slide="slidestop" does-continue="false">
And in your controller add
$timeout(function(){ $ionicSlideBoxDelegate.enableSlide(false); },0);