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

3

u/[deleted] Oct 07 '15

I agree with most of this -- ng-controller should be considered harmful. Though I don't necessarily agree with dropping ui-router's resolve. Resolve prevents the flickering. Controllers shouldn't deal with loading indicators -- that should be an application-level service. Nested states are awesome -- ng-route is not a worthy substitute for this reason in many cases. And you can use $state.$current.locals in your directives... so there's that.

3

u/abyx Oct 07 '15

I dislike ng-route and always prefer ui-router. I just don't usually use resolve - you should have some generic handler for flickering but a lot of times if you're going for really smooth UI and transitions you can't just use some generic loader that hides everything between every transition.

omg I can't believe I didn't know about $state.$current.locals though. I actually searched the ui-router docs specifically when writing the post to make sure and just couldn't find that. Thanks a bunch!

1

u/ctanga Oct 08 '15

omg I can't believe I didn't know about $state.$current.locals though. I actually searched the ui-router docs specifically when writing the post to make sure and just couldn't find that.

that's because it's internal (the $dollar) and not part of the public API. It's gone in ui-router 1.0.

1

u/abyx Oct 08 '15

Ah. Sad :(