Created
April 22, 2015 08:18
-
-
Save islahul/506692c9276ff2f8987b to your computer and use it in GitHub Desktop.
Unbind / Deregister Ionic registerBackButtonAction
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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