-
Notifications
You must be signed in to change notification settings - Fork 27.4k
$onDestroy not called on Controller but $scope.$on($destroy) is #15073
Comments
I can't see in the example where the controller actually gets destroyed, so it's hard to say where the problem is. Also note that $onDestroy is called when the containing scope is destroyed. |
The controller is setup using controllersAs to avoid injecting scope in.. but when I do inject scope in destroy is called... to me that means the scope of the route is getting killed but not calling the controller $onDestroy. This route is a main route on the global ui-view of the page. I simply navigate back and forth in these routes but nothing fires. |
This looks like a |
@dcherman $onInit and $onChanges all work and $onDestroy works in other controllers I have.. but on main routes it doesn't.. ui-router definitely supports it. but certain routes dont get called and I'm noticing just root routes. Routes that are top level vs child components and child routes. Ill do some more investigating. |
So i just did some refactoring and if i Route to a component vs a controller the $onDestroy works so my state now looks like
now when i navigate to those components based on my stateprovider:
all the proper events fire.. |
Can you even reproduce the problem without ui-router? |
This seems like a duplicate of #14376. There is a misconception that More specifically, The only case, where Closing since this is working as expected as far as Angular is concerned. If you think there is a bug with |
Having an issue with the $onDestroy of a Route controller not getting called.
I can't seem to get the $onDestroy to ever fire.. if i remove the inject of scope that doesn't help either..
I am using angular 1.5.8, this happens on all browsers.
Below is the routes file that i'm using.
This issue happens on all children routes as well.
The text was updated successfully, but these errors were encountered: