AngularJS scope & inheritance - Love/Hate relationship

When I was working on the TickerSrv, I wanted to support task auto-unregister. To accomplish that, in the module’s run phase, I added register & unregister functionality to the $rootScope.

Since all scopes prototypically inherit from $rootScope, all had this functionality and the user could use this scope API to register or unregister tasks. More over, when the scope is destroyed, I can intercept the event and unregister the tasks automatically.

As it turns out, isolated scopes behave differently.
First, for those who are not familiar with isolated scopes, those are the scopes that directives get, when you specify scope: { ... }. This creates an “isolate” scope that does not prototypically inherit from $rootScope.

This poses a real problem for my TickerSrv auto-unregister functionality, since I can no longer rely on this API to exist on the scope.

So, I had to resort to a bit of a hack.

Read more here