Unfortunately, you can’t prevent hiding the modal with capturing event ‘modal.hidden’ since the modal is already hidden and the event is just a notification saying the the modal is now hidden.
You can use another approach and control when the modal will be closed, by controlling when the method modal.hide() will be called.
Basically, you have to do 3 things:
- When calling
$ionicModal.fromTemplateUrl, set the properties
hardwareBackButtonClose to false
- On back button click use you own:
$scope.hideModal where you will check if isPassed is true or false.
- Register your own back function to handle hardware back button, with:
registerBackButtonAction. Take a look at: http://ionicframework.com/docs/api/service/$ionicPlatform/
I’ve created a codepen that shows 1. and 2.: