Event after Modal show


I need run some code after Modal show,
how can I catch the event ?




From http://ionicframework.com/docs/api/controller/ionicModal/

Note: a modal will broadcast ‘modal.shown’ and ‘modal.hidden’ events from its originating scope, passing in itself as an event argument.

$scope.$on('modal.shown', function() {
  console.log('Modal is shown!');


Thanks rdelafuente !

but if I got more than one modal,
how can I figure which one is opening ?



Hi @jasonshow!

I understand your scenario. What you can do is assign an ID to your modals and use that ID in the broadcasted messages to identify which modal is being shown / hidden / removed.

$ionicModal.fromTemplateUrl('modal-1.html', {
    id: '1', // ID to identify the modal that is firing the event
    scope: $scope,
    animation: 'slide-in-up'
}).then(function(modal) {
    $scope.oModal1 = modal;

Take a look at this basic example with two modals: http://codepen.io/rdelafuente/pen/axeph

Hope it helps!


Thanks rdelafuente !
everything is cool now !


saved my day. thanks!