Reputation: 5522
How do I separate AngularJS controllers/services/routes by section of my app? For example, I have sections such as:
I want to put all controllers/services etc into separate JS files, but don't want to have to have a long list of includes in my index.html.
Upvotes: 0
Views: 89
Reputation: 9839
What we do in our projects, is we use a build process that concatenates all .js
and .css
files into 2 big minified files and we include them inside index.html
. we name them something like app-all.min.js
and style-all.min.css
.
There are quite a lot of tools that do file concatenation, we use maven plugin for that but you can use a grunt or a gulp task if maven isn't your thing.
Then you define which sub-directories in your project you want to concat and which to ignore. so your your file/directory layout isn't really an issue.
As for app structure, there are some very opinionated discussions out there about how you should do this. I found John Papa's angular style guide section about application structure the most definite and widely used
Upvotes: 2