Skip to content

Instantly share code, notes, and snippets.

@islahul
Created April 22, 2015 08:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save islahul/506692c9276ff2f8987b to your computer and use it in GitHub Desktop.
Save islahul/506692c9276ff2f8987b to your computer and use it in GitHub Desktop.
Unbind / Deregister Ionic registerBackButtonAction
// To solve weird android behaviors we need to manually implement Hardware back-button actions sometimes
// $ionicPlatform.registerBackButtonAction returns a deregister function
var deregisterFunction = $ionicPlatform.registerBackButtonAction(backButtonAction, 500);
// Example way of unbinding
if(something === false) {
deregisterFunction();
}
// Or if registered for a particular view / page
$scope.$on('$destroy', deregisterFunction);
function backButtonAction() {
// Does something
}
// Reference which was really hard to find when I ran into this issue
// http://forum.ionicframework.com/t/tutorial-to-learn-about-hardware-back-button/5200
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment