I group all code that are in one module together and create common folder for things everyone shares. I also use browserify to concatenate all files into 1 file. The code is broken down into classes so it is easy to migrate to angular 2. It is a mix of both MVC style and feature based.
/app entry.js //load in all modules /scss main.scss //concatenate all non underscore scss /marketing _home.scss marketing.scss // concatenate all _ scss ... /common /model /services index.js //bind all classes in services into index.js /http HttpService.js //Class /utility Utility.js //Class index.js //bind all classes in utility into index.js /uicomponents index.js //bind all classes in uicomponent into index.js /spinner Spinner.js //Class ... /marketing index.js //bind all modules into index.js routes.js //array of all routes /models UserModel.js //Class index.js //bind all classes in model into index.js /services index.js //bind all classes in services into index.js /user UserService.js //Class ... /views /directives index.js //bind all classes in directives into index.js /somewidget SomeWidget.js //Class /modals index.js //bind all classes in modals into index.js /somemodal SomeModal.js //class /pages index.js //bind all classes in page into index.js /home HomeController.js home.html /admin // same as marketing /member
So what I did was make every Controller, directive, service into a javascript class which you can DI angular properties.
1 2 3 4 5 6 7 8 9 10 11 12 13
var SomeController = function ($scope, $state, $log) { vm._scope = $scope; vm._state = $state; vm._log = $log; };
By doing this, we remove our codes dependancy on angular making it reusable by in the future. $scope can be injected in as something else. You can also test this class individually now without needing angular.
The index.js file in the high level module would look like this: