I am using ui-router and am trying to detect when a controller belonging to a view that's being transitioned away from gets destroyed.
So I currently have a destroy
listener like so:
$scope.$on('destroy', function(){
mySpecialFunction();
});
However, when a state change occurs to a different view\controller, this destroy event never fires.
The state I am transitioning to, is a sibling state so I'm going from myParent.childA
to myParent.childB
(where childA has the destroy listener added).
If I was instead going from myParent.childA
to myParent.childA.child1
then this would make sense since childA still exists in the hierarchy.
Can someone help me understand why the scope still exists in this scenario please?