Comments (2)
Hi @LucasCaixeta, there are a lot of different ways that people layout their folder hierarchy. Originally it was something like:
/controllers
/directives
/services
But if your application needs to be scalable this will cause lots of growing pains. So others have adopted structures that nest based on the URL or based on your understanding of the UI, which I'll outline below in 3 points:
- Assuming basing your folder structure on URL is self explanatory I'll just say the amount of folders you have will balloon.
- Using the UI you can split your folders into the below structure where a major feature might be tabs and minor features are the tabbed content with associated component folders. Arguably adding your services into the feature folders might be a bad idea, especially if they cross cut components, so you could add them to a /services folder in the root so you can actually find them and so services aren't written that already exist. Each feature gets its own appjs and is subsequently required by your mainJS.
/major-feature-1
/minor-feature-1
controller.js
directive.js
service.js
/minor-feature-2
...etc
/services
cross-cutting-service1.js
cross-cutting-service2.js
- Another take on the last example is using the pages of the application as the folder, which contains the components with their own files, but where services that crosscut are also placed in the root maybe even in a /common folder instead of just /services. Each page gets its own appjs and is subsequently required by your mainJS.
/page
/component
controller.js
directive.js
service.js
/common
/services
cross-cutting-service1.js
cross-cutting-service2.js
These are examples of all the ways I've read about and have evolved to use, but I'd be interested to know what others have to say with regards to the style guide. Either with other examples and why they are better or tweaks to one of the offered solutions.
Also, I believe this style guide and John Papa's parallel to a degree and diverge where they disagree, but John Papa has an application structure section.
Cheers
from angularjs-styleguide.
Closing off as this is now in the new styleguide which has been completely rewritten in ES6 for Angular 1.5+ (component architecture/components/one-way dataflow etc).
from angularjs-styleguide.
Related Issues (20)
- Yeoman generator for this style guide HOT 3
- Somekind of a new syntax with ng1.6 controllers.
- feature request: Advice on using Interface
- Missign injectable in directive with Classes
- Parent component trigger function in child component HOT 5
- Life without factories HOT 1
- Granularity of Modules HOT 1
- class constructors must be invoked with |new| HOT 1
- Wrong example in directive
- ng-annotate HOT 4
- index.js (index.ts) usage
- syntax error(s) in Typescript directive section for TodoAutoFocus as TS Class
- Register service with static constructor function? HOT 1
- calendar issues with table cell width with title column header
- Translating README to Spanish HOT 4
- Typescript Version: Which @types/angular version was used?
- reuse filters across components HOT 1
- Can't access form object in component's controller HOT 1
- Circular dependencies
- Spanish translation is old and don't match with current code.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from angularjs-styleguide.