Each time you click the Back button, only one event is executed, and the original default action is applied when the condition is not met in the custom event. If you are monitoring only in one view, you also need to log off the event in a timely manner.
Http://www.jianshu.com/p/b567cc657a49
http://blog.csdn.net/liangyiyiliang/article/details/53507411
//Return key, view:100, condition not satisfied then execute default event$scope.Homebackregister = $ionicPlatform.registerbackbuttonaction(function(event){ function showconfirm(){ varConfirmpopup= $ionicPopup.Confirm({ title: ' <strong> exit application?</strong> ', Template: ' Are you sure you want to quit? ', Oktext: ' exit ', Canceltext: ' Cancel ' }); Confirmpopup. Then(function(RES){ if(RES){ Ionic.Platform.Exitapp(); } Else { $rootScope.Backcount = 0; } }); } if($state.$current.name == ' Home.index '){ $rootScope.Backcount = $rootScope.Backcount || 0; $rootScope.Backcount++; if($rootScope.Backcount == 2){ showconfirm(); } Event.Preventdefault(); return false; } Else { Navigator.app.backhistory(); }}, 101);//Sign out only under current view, logout event$scope.$on(' $destroy ', $scope.Homebackregister);
Ionic Android Back button