3 ms·
Finally, someone with opinion, so far most articles on the topic have been too soft in terms how an Angular app should be written and organised. However there
by tzaman 12y ago
Finally, someone with opinion, so far most articles on the topic have been too soft in terms how an Angular app should be written and organised.
However there is one point I disagree with: files and folders should be organised per-feature/functionality, not Rails-like. When you have 40+ services, and 100+ of directives, it can become tedious to work on these separate files. That's why I recommend to put files that do common stuff together. For example we have auth folder that holds the service, a couple of directives (like for password inputs), all possible states (we use ui-Router) and controllers, in total 8 files: http://cl.ly/image/2o0Q1n1m2M32 http://cl.ly/image/2o0Q1n1m2M32
- acconrad 12y agoIt depends on the size of your codebase. For small codebases, I separate folders by object type (e.g. apps/, /controllers, /directives), but as codebases grow in size, we have adapted to the style you mention, separating by functionality.
- joekrill 12y agoI agree. And this is pretty important, I think. I struggled with various ways to handle file structure when I first started with Angular because most example/guides used the type of structure Todd shows as "Good". But I found things became very cluttered very quickly that way.