angular-strap icon indicating copy to clipboard operation
angular-strap copied to clipboard

Listening for $modal events ('open','close')

Open btmdave opened this issue 13 years ago • 8 comments

I'm using the modal directive, can't seem to figure out how to listen to events, is this possible? I'm opening a modal using the directive, not service and assigning to a controller.

Thank you!

btmdave avatar Apr 19 '13 22:04 btmdave

Since event bubble up, you just have to use:

$scope.$on('modal-shown', function() {});

in one of the parent controllers.

mgcrea avatar Apr 20 '13 10:04 mgcrea

This still works? Can you help me with this plunk?

http://plnkr.co/mDpWyiJAQdeU0vTfEzWg

thanks in advance!

moisesbaddini avatar Jan 28 '14 02:01 moisesbaddini

This doesn't seem to be working anymore, if ever. I'm listening on the parent scope, but the event modal-shown or modal-hidden is never called.

eranimo avatar Apr 15 '14 16:04 eranimo

As with @eranimo, it looks to me like it's not working anymore; does anyone know if the event is still being fired, or if there's an alternative way to watch for a modal being closed?

luke-bravenboer avatar May 02 '14 03:05 luke-bravenboer

You can use it like this: $scope.$on('modal.hide',function(){ console.log("hide"); }); $scope.$on('modal.show',function(){ console.log("show"); });

iuliansafta avatar May 05 '14 10:05 iuliansafta

there's more details in the source, basically look for any emits ->

https://github.com/mgcrea/angular-strap/blob/master/src/modal/modal.js

note there seems to be a bug in the aside code where it emits with modal prefixs, just in case your trying to get aside events

Anthony-Mckale avatar Jul 15 '14 09:07 Anthony-Mckale

$scope.$on('modal.shown', function() {}); is ok!!

FHJ2020 avatar May 16 '15 12:05 FHJ2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

lock[bot] avatar Jan 26 '19 04:01 lock[bot]