r/angularjs • • Oct 07 '15

Angular 2 Preparation: Killing Controllers

http://www.codelord.net/2015/10/07/angular-2-preparation-killing-controllers/
46 Upvotes

19 comments sorted by

View all comments

2

u/ninjasorcerer Oct 08 '15

You don't even need to put the controller code directly in the directive. You can just reuse it by injecting it with the string syntax. This way you can also share it between a directive and a ui-route for example. Keep things decoupled as much as possible! You're still using it as a controller so the title is also misleading.

2

u/abyx Oct 08 '15

I'm not sure I understood your point. I specifically don't want to reuse controllers in ui-routes. I want them to always be encapsulated inside directives, thus killing the prototypical hierarchy of scopes and achieving total isolation. The logic part inside a directive is also called a controller, but that's not a standalone controller - those ones we've killed are got rid of.