How to disable back button with $ionicPopup?


#1

I am showing a popup when user is offline and Currently User can close $ionicPopup using hardware Back button . But I don’t want user to close the popup unless he perform any action.

I tried following but it is not working:

$ionicPlatform.onHardwareBackButton(function (e) {
if($cordovaNetwork.isOffline()) {
e.preventDefault();
return false;
}
})


#2

Anyone having solution to this problem?


#3

Try this:

var deregisterBackButton;
var alertPopup;
$scope.showAlert = function() {
	     
        deregisterBackButton = $ionicPlatform.registerBackButtonAction(function(e){}, 401);
        alertPopup = $ionicPopup.show({
	          ...
        });
	                
        alertPopup.then(function(res) {
	            deregisterBackButton();
        });
};