I don’t think this question is considered opinion-based as it asks for best practices, but at the same time I don’t think that there are any industry standards for AngularJS best practices, so it’s hard to avoid “strong” opinions in some cases . In other cases, one way of programming is clearly better than another. I am not sure in which category this issue falls under.
I don't think there are any official AngularJS best practices. There are recommendations, and some people have released their own best practices, but I have not stumbled upon an industry standard.
I have a question about how I organize my modules and the code itself. It looks like I have a lot of small files and too many folders, although I split the application into common components and basic functions. This is still a relatively small application, but it is likely to grow.
The biggest question I had was how I should organize my submodules. Currently, each submodule is divided into different files, separating controllers, directives and services. I was wondering if you should just define them all in one file, and then if the submodule gets too big, break it again.
For example, right now I have an app.buttonToggle module , with various files:
buttonToggle.app.js
angular.module('app.buttonToggle', []);
buttonToggleCtrl.js
angular.module('app.buttonToggle').controller('ButtonToggleCtrl', ButtonToggleCtrl);
function ButtonToggleCtrl() ...
...
buttonToggle.js
angular.module('app.buttonToggle').directive('buttonToggle', buttonToggle);
function buttonToggle() ...
...
Instead, would it be better to merge them into a single file?
buttonToggle.app.js
angular.module('app.buttonToggle', [])
.controller('ButtonToggleCtrl', function() { ... })
.directive('buttonToggle', function() { ... });
, ? , , ?