hgo
1
Hi,
Is there a way to listen state back (on android -> back button, on ios -> swipe left) event on ionic as mobile web (not in a cordova app) ?
I want to check if an ionicModal shown. If so; close this modal and prevent to state change?
$ionicModal handles all this mess within a cordova app but I cannot find any solution while using it as mobile web application.
hgo
3
The solution;
.directive('modalHide', function () {
return {
restrict: 'A',
scope: true,
link: function (scope, element, attrs) {
var _modal,
_dereg;
scope.$parent.$on('modal.shown', function (e, modal) {
_modal = modal;
_dereg = scope.$on('$stateChangeStart', function () {
_modal.hide();
});
console.info("show", scope.$$listeners.$stateChangeStart)
});
scope.$parent.$on('modal.hidden', function (e, modal) {
_dereg && _dereg();
console.info("hide", scope.$$listeners.$stateChangeStart)
})
}
}
})