Modal and Android Back Button


#1

Anyway to change the Android Back Button to remove instead hide?

When I click on the Android Back Button, only calls $scope.myModal.hide(), but I want to remove that modal completely(calling $scope.myModal.remove());

I try to use:

$scope.$on('modal.hidden', function(e, i) {
i.remove();
});

but it returns a infinite loop, because the .remove() calls the .hide()


#2

Hi,
Maybe this will help:
http://ionicframework.com/docs/api/service/$ionicPlatform/

Try:

$ionicPlatform.onHardwareBackButton(callback)

or

$ionicPlatform.registerBackButtonAction(callback, priority, [actionId])

#3

Can you please tell me what is the actionId ?


#4

It is just a unique identifier that you can add to your button action. But it is optional parameter so you dont’ have to use it. If you don’t use it, Ionic will assign random unique id.


#5

can you give me some example in html and script file for actionId ?