Modal and Android Back Button

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()

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

Try:

$ionicPlatform.onHardwareBackButton(callback)

or

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

Can you please tell me what is the actionId ?

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.

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