$ionicPopup can't be closed if back button is pressed


#1

Hey,

I encountered a problem with $ionicPopup : When I open a Popup, and then press the back button, I am not able to close it anymore. This problem happens only if I use the option scope of $ionicPopup :

This Works : (I can close the Popup even if I pressed back button)

deregisterBackButton = $ionicPlatform.registerBackButtonAction(function(e){}, 401);
alertPopup = $ionicPopup.alert({
 	  title: title,
 	  template: '<div class="item-center">' + template + '</div>',
      buttons: [
          {  
              text: 'OK',
              type: 'button button-clear button-energized',
          }
      ]
 	  });
      alertPopup.then(function(res) {
          deregisterBackButton();
      });

This, does not work : (I can’t close the popup when back button is pressed with scope is used)

deregisterBackButton = $ionicPlatform.registerBackButtonAction(function(e){}, 401);
alertPopup = $ionicPopup.alert({
 	  title: title,
 	  template: '<div class="item-center">' + template + '</div>',
      buttons: [
          {  
              text: 'OK',
              type: 'button button-clear button-energized',
          }
      ]
 	  });
      alertPopup.then(function(res) {
          deregisterBackButton();
      });

Where does this can come from…?


#2

You’ve overridden default back button action with priority 401.

Everything above 400 will prevent popup closure.


#3

So there is no link with scope use ?
At the moment I’m using my app on Chrome : and when I press back button of navigator, I can’t close it only if I use the Scope in $ionicPopup…
And if I don’t use the deregisterBackButton, I can’t close both.
Maybe I’m Wrong somewhere…


#4

I think it’s a combination of everything said


#5

Then another question is why If i go back in Chrome when a simple Popup is open, I can’t close it anymore…?

For example this very simple Popup :

alertPopup = $ionicPopup.alert({
    title: title,
 	template: '<div class="item-center">Test</div>',
    buttons: [
        { 
            text: 'OK',
            type: 'button button-clear button-energized',
         }
     ]
});