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/[deleted] Oct 07 '15

if you're going for really smooth UI and transitions you can't just use some generic loader that hides everything between every transition

There's no reason you need to hide everything. I'd be really surprised to find a use case that couldn't be handled by a dedicated transition service.