TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

AngularJS Style Guide

118 点作者 harrisonp超过 10 年前

12 条评论

MaybiusStrip超过 10 年前
I still don&#x27;t understand why everyone recommends different folders at the project root for controllers, directives, services, etc... You end up with closely related code being far apart. It&#x27;s a thoughtless way of dividing up your files based on the most obvious feature rather than how things actually fit together.<p>My idea of a good modular file structure is that you could delete any random directory and delete it and it would lop off that feature as cleanly as possible. Each directory should represent an angular module, and each module should contain the routing, controllers, services, directives, and tests that it uses. If some of these are used across the app then you can have a &quot;common&quot; module.
评论 #8452315 未加载
cageface超过 10 年前
I&#x27;m coming back to JS development after several years away and my first impressions of Angular are that it seems very complicated and over-engineered, with a lot of fairly abstract concepts to digest to get even simple things working. React.js seems so much simpler but there does seem to be a lot of community support for Angular.<p>Should I invest the time and learn Angular or go with React instead? Web components seem likely to change the whole web development landscape but my impression is that they&#x27;re not quite ready for prime time yet.
评论 #8447703 未加载
评论 #8452330 未加载
评论 #8447691 未加载
MrOrelliOReilly超过 10 年前
Very helpful. I&#x27;ve unsuccessfully search for a way to do one-time binding before in a data intensive application and never came across the {{::ctrl.foobar}} syntax.<p>One thing I&#x27;m hesitant about is their advice to use directives instead of ng-controller=&quot;MyCtrl&quot;. Since controllers really are app specific glue code I rarely find myself wanting to reuse them - what advantages are directives supposed to give here?
评论 #8446525 未加载
评论 #8446456 未加载
评论 #8446425 未加载
awinder超过 10 年前
Anyone have experience one way or the other with the pattern of including test files with the features as opposed to under an alternate directory structure? I usually put tests and application code in parallel directories so that the tests are all in one place, but curious if anyone has seen big advantages one way or the other
评论 #8447327 未加载
评论 #8448062 未加载
mck-超过 10 年前
Todd Motto&#x27;s angular style guide [1] has been one of the most helpful to me. It&#x27;s always good to read multiple style guides and cherry-pick what works best for you :)<p>[1]: <a href="https://github.com/toddmotto/angularjs-styleguide" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;toddmotto&#x2F;angularjs-styleguide</a>
评论 #8446446 未加载
andrewstuart2超过 10 年前
I find myself counter to the popular opinion on the use of controllerAs for mostly semantic reasons (IMO, a controller orchestrates services, $scope included, rather than containing data or references to data), though there are obvious and not-so-obvious tradeoffs with either choice.<p>That said, this style guide definitely has the strongest (almost convincing) argument I&#x27;ve seen for using controllerAs and does not have the inconsistencies I&#x27;ve found in other guides (`this` is not bound to `$scope` as a couple popular guides claim). Good stuff.
theflubba超过 10 年前
Meh. NgAnnotate is way better than duplicating code. Be DRY, not pedantic.
评论 #8446912 未加载
评论 #8447876 未加载
评论 #8446928 未加载
craigching超过 10 年前
A minor nit, the TL;DR is just an outline. I was hoping for a simple statement of the problem with a conclusion and the rest of the article would present the details, more of a real overview or synopsis.
评论 #8447436 未加载
Eric_WVGG超过 10 年前
I got a lot out of this. I’ve never worked in a platform that evolves as rapidly as Angular, and have found myself blinded by “last year’s advice” a few times. Quite a bit of modern thinking here.
bibonix超过 10 年前
logically this should come from Google (the author of AngularJS)... anyway, thanks, I&#x27;ll definitely try to use it
wooptoo超过 10 年前
Is this article an ad?
评论 #8448065 未加载
boulos超过 10 年前
The actual post title is: &quot;The GoCardless AngularJS Style Guide&quot;. I was expecting something about how they needed to do XYZ to make Angular <i>run</i> well rather than how they scale up <i>development</i>.
评论 #8446099 未加载