2
votes

I have a tab page in the project, on click of Android hardware back button supposed to back to previous tab instead of previous page. How to do that?

More specifically, is there any way to override back button per controller(page) instead of in app.js?

1
I came across this but didn't notice the answer I want in the second page. Thanks! ;)Lee Chun Hoe
@USKMobility I am using registerBackButtonAction in controller. It supposed to be deregistered after called by $scope.$on($destroy, deregisterFunction), but it still persist on other page. Any advice?Lee Chun Hoe

1 Answers

0
votes

Answer from http://www.gajotres.net/ionic-framework-handling-android-back-button-like-a-pro/2/.

app.controller('TheFirstController', function($scope, $ionicPlatform) {
    var deregisterFirst = $ionicPlatform.registerBackButtonAction(
      function() {
        alert("This is the first page");
      }, 100
    );
    $scope.$on('$destroy', deregisterFirst);
});