Closed amitport closed 7 years ago
If I'm not mistaken, unregistering the directive in your example isn't going to work, as you are simply registering another directive with the same name that does nothing.
As for unregistering, I'm not sure if it is a common feature, but it would probably work reasonably easy for services etc. but directives might be more difficult because you can register the same name multiple times.
This is out of scope for AngularJS
use case: I have many routes in a single page app, in some routes I want to define controllers and directive (and possibly other injectables) that should only be available in those routes.
In order to avoid memory bloating and name collision (for directive/controller names etc.), I want to unregister such injected objects when leaving each route.
If I understand correctly, this is possible using something like:
but this is very ugly and it would be nice if the following would be supported: