Todd Motto's angular style guide [1] has been one of the most helpful to me. It's always good to read multiple style guides and cherry-pick what works best for you :) [1]: https://github.com/toddmotto/angularjs-styleguide
The recommendations in the module section are pretty awful - I'd avoid doing so, and every other expert in the community I've spoken to also disagree with that suggestion of using global functions wrapped in an IIFE to prevent it from being published on window, which seems to exclusively come out of Google.
AngularJS Style Guide
31–40 of 41 posts
Re: AngularJS Style Guide
#32Todd Motto's angular style guide [1] has been one of the most helpful to me. It's always good to read multiple style guides and cherry-pick what works best for you :) [1]: https://github.com/toddmotto/angularjs-styleguide
The recommendations in the module section are pretty awful - I'd avoid doing so, and every other expert in the community I've spoken to also disagree with that suggestion of using global functions wrapped in an IIFE to prevent it from being published on window, which seems to exclusively come out of Google.
Re: AngularJS Style Guide
#33Earlier quoted context omitted.
That's reassuring. I look at some of the code examples and all the $vars and it looks very obscure. I guess the forthcoming 2.0 version is supposed to simplify things a lot and make it play nicely with web components though so maybe it's worth getting on board now.
To contrast with what the OP said, I found Angular pretty cool at the beginning but got more and more annoyed as I progressed. If you're okay with interacting with a black box, go for it otherwise choose react.
An example is Angular's treatment of HTML forms and input elements, w.r.t. things that you'd expect, such as name / id interpolation (namely: Angular doesn't interpolate dynamic form names as you'd expect - [1] and [2]). In cases like this, digging into the internals to resolve the initial surprise and later solve the problem was slightly frustrating.
Re: AngularJS Style Guide
#34Meh. NgAnnotate is way better than duplicating code. Be DRY, not pedantic.
Re: AngularJS Style Guide
#35Re: AngularJS Style Guide
#36Anyone 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
Re: AngularJS Style Guide
#37Is this article an ad?
Re: AngularJS Style Guide
#38My 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 "common" module.
Re: AngularJS Style Guide
#39Meh. NgAnnotate is way better than duplicating code. Be DRY, not pedantic.
I have heard that it has trouble working in a complex build/development environment, e.g. when watching live file changes* with gulp/browserify. *) https://www.npmjs.org/package/gulp-watchify/
Feel free to open issues and I'm sure it will be addressed.
ng-annotate itself just produces output for input (stdin/stdout or via files) so it does not at all have any trouble participating in a "complex build environment".
Re: AngularJS Style Guide
#40I still don'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's a thoughtless way of dividing up your files based on the most obvious feature rather than how things actually fit together. My idea of a good modular file structure is that you could delete any random directory and delete it and…
This seems to be because certain of what makes up each set of functionality "bleed" together - models, in particular, all seem to end up relying on each other.
I think the MVC / CDS, etc organizational structures are less about grouping things by feature and more about grouping things by common "bleed" factors (or, more likely, some deeper commonality that then causes the shared amount of "bleed"). Views pretty much never share anything. Controllers share utility functions. Models just go spaghetti.
You can also think of it like a toolbox; I keep all the screws together, rather than keeping all the flat-head screws with the flat-head screwdrivers.
That all said - Yeah, that's an excellent ideal, but it's not one that seems to occur in practice.