-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Closed $modal reference kept in memory but not in DOM? (>=0.9.0 only) #1778
Comments
Note also that if you launch/close the modal multiple times, and then click on CloseAll, multiple exceptions are generated (one for every modal). |
Here is the exception: |
The CloseAll listeners aren't being cleaned up because you're adding them to the $rootScope. Listeners added to the $rootScope will never be removed unless you remove them manually. What you probably wanted to do is to listen on the $scope of the modal for the CloseAll event. Also note that you can use |
Just re-looked into this and found the problem in your code. Please re-open if this issue isn't resolved. |
@chrisirhc Yep what you said about having the listener on $rootScope makes sense. I was using $rootScope rather than $scope for performance reasons, so that I can $emit down the tree (which in the case of $rootScope ends at $rootScope) rather than $broadcast up it. But I could always clean up these listeners myself. Is there a way to override or extend the close or destroy method triggered by $modalStack.dismissAll? I need different modals to respond differently to the 'close all' request. Still I wonder why it is these listeners seem to be automatically cleaned up in <=0.8.0 but not in >=0.9.0. Perhaps it is actually a bug in <=0.8.0 where they should not be getting cleaned up but somehow they are. |
It looks as though a reference to a closed $modal is being kept in memory, even when the modal is removed from the DOM. This happens when I use $rootScope.$on() in the modal's controller.. I'm not sure if it happens without it.
I can reproduce in >=0.9.0 but not <=0.8.0 with latest Chrome browser.
Plunkr: http://plnkr.co/edit/ahB5ScVghWr1ZRcvPWlz
Update: On second thought it looks as though the problem might be with the $on listener not being cleaned up.
The text was updated successfully, but these errors were encountered: