preventDefault on ionicView Events and retrigger them


Hello, is it possible to cancel the switching of a view with the view events like “$ionicView.beforeLeave” and retrigger them?

What i want to achieve is to fire a popup to ask if the user really wants to switch the view (for example on a form view, i want to prevent that the user accidentally leaves the view). If he really wants to leave the view, i want to retrigger the event.

I have a workaround for this, but its pretty dirty because of the back button handling. Otherwise i could just something like the onStateChange Events, but with a custom back button which uses window.history.back it doesn’t work that way. So in my current project i have two different behaviours for one “feature” and as i said its pretty dirty.

With the new view events i hoped i could implement that in a nicer way.

Appreciate any help.


I would also like to prevent the user from leaving the view.

$scope.$on('$ionicView.beforeLeave', function(e) {

Doesn’t seem to work…


Any news here? I need exactly the same in my project.

edit: I found the issue for it bug: event.preventDefault() doesn’t work in view lifecycle events