Do you tried using $ionicHistory.nextViewOptions? http://ionicframework.com/docs/api/service/$ionicHistory/
$ionicHistory.nextViewOptions({
disableBack: true
});
I'm sure that with historyRoot: true swipe to go back doesn't works, but with disableBack: true I'm not sure.
:+1:
I tried what @felquis suggested, but it didn't work.
You should be able to disable it in the state's controller. Something like:
.controller('MyCtrl', function($scope, $ionicConfig) {
$scope.$on('$ionicView.enter', function(){
$ionicConfig.views.swipeBackEnabled(false);
})
$scope.$on('$ionicView.leave', function(){
$ionicConfig.views.swipeBackEnabled(true);
})
});
Does that do the trick?
@perrygovier Thank your for your feedback.
I added to the controller of the according state/view.
Both functions are firing, either on enter and leave as expected.
However I still can swipe to leave the state/view.
I tested on 1.0.0-rc.0 and 1.0.0-rc.3
@perrygovier This maybe along the same lines as https://github.com/driftyco/ionic/issues/3281, where change the config value in the controller did nothing.
If thats the case, this would be a bug and not a feature. Passing this to @adamdbradley
Hi @adamdbradley
Thank you for your work on this issue.
I upgraded to 1.0.0-rc.4 and the code below still does not prevent "swipe to go back".
(tested in Ionic View)
.controller('MyCtrl', function($scope, $ionicConfig) {
$scope.$on('$ionicView.enter', function(){
$ionicConfig.views.swipeBackEnabled(false);
})
$scope.$on('$ionicView.leave', function(){
$ionicConfig.views.swipeBackEnabled(true);
})
});
@yankustefan neither works in rc.5 :-(
Ah @yankustefan simply use can-swipe-back="false" on your ion-view element
+1 @yankustefan
I have the following code (that I believe should be the default on iOS, but whatever) :
$scope.$watch(function () { return $ionicSideMenuDelegate.isOpenRight(); }, function (isOpen) {
if (isOpen){
$ionicConfig.views.swipeBackEnabled(false);
} else {
$ionicConfig.views.swipeBackEnabled(true);
}
});
Not working :'(
The problem I have is the following :
ion-side-menu side="right" and a ion-nav-view ion-nav-view)Is that clear enough ? I can make a video since it's pretty specific, if necessary.
Regards
Also pinging @adamdbradley
following is not work
.controller('MyCtrl', function($scope, $ionicConfig) {
$scope.$on('$ionicView.enter', function(){
$ionicConfig.views.swipeBackEnabled(false);
})
$scope.$on('$ionicView.leave', function(){
$ionicConfig.views.swipeBackEnabled(true);
})
});
@seb0zz Have you tried programmatically?
Like this: can-swipe-back="canSwipe()"
$scope.canSwipe = function(){
return true;
}
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.
Most helpful comment
Ah @yankustefan simply use
can-swipe-back="false"on yourion-viewelement