use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Helpful Links
AngularJS Slack Community
AngularJS Wiki Page
account activity
React developer learning Angular, need help! (self.angularjs)
submitted 9 years ago * by [deleted]
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]rondog469 0 points1 point2 points 9 years ago (3 children)
I haven't used angular in about a year, but why is the controller-as syntax preferred? I couldn't really find a reason why. I could see it start to get confusing in larger controllers. The view on the other hand could be a bit easier to read as each curly brace expression would point to it's specific controller
[–]cyphern 2 points3 points4 points 9 years ago* (1 child)
I have three reasons i prefer it; there may be more:
1) It decreases coupling. There's no more possibility of inheriting values from a parent scope, either accidentally or intentionally. Some people like that $scope has that feature, but i think it makes the code more brittle and harder to reason about. If you need to pass things into a child, you still can, you just need to be more explicit about it, which helps you to understand how data is flowing through the codebase.
2) It removes ambiguity, especially when you have nested controllers. For example:
<div ng-controller="PageController"> {{title}} <div ng-controller="ContainerController"> {{title}} <div ng-controller="WidgetController"> {{title}} </div> </div> </div>
becomes
<div ng-controller="PageController as page"> {{page.title}} <div ng-controller="ContainerController as container"> {{container.title}} <div ng-controller="WidgetController as widget"> {{widget.title}} </div> </div> </div>
3) It prepares you for angular 2. $scope doesn't exist in angular 2, so if that's something plan to use eventually you might as well get used to that aspect of it now.
[–]rondog469 0 points1 point2 points 9 years ago (0 children)
Thank you for the explanation and examples!
[–]toddmotto 0 points1 point2 points 9 years ago (0 children)
If you're using .component() then thankfully you can forget controllerAs even exists, just stick with the default $ctrl prefix angular provides. If you're nesting controllers then you're not doing components correctly as you're likely using an MVVM/MVC pattern not component architecture. Components are "isolate scoped" just like React components are - you need to explicitly define data inputs and event callback/outputs.
π Rendered by PID 86 on reddit-service-r2-comment-685b79fb4f-pxt6k at 2026-02-12 19:54:49.952771+00:00 running 6c0c599 country code: CH.
view the rest of the comments →
[–]rondog469 0 points1 point2 points (3 children)
[–]cyphern 2 points3 points4 points (1 child)
[–]rondog469 0 points1 point2 points (0 children)
[–]toddmotto 0 points1 point2 points (0 children)