Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MEANJS boilerplate : where to include custom javascript files?

I started using the Mean JS boilerplate (ref website) and would like to know where the recommended place to include public custom javascript, jQuery files (ex. FacebookSDK, jQuery animations,...) .

I'm assuming it's going to be somewhere in the public folder. The default structure is as follows : enter image description here

Should it go in modules or lib folder? Can you give more guidelines on what the function of each folder is? Any guidelines?

like image 469
BassMHL Avatar asked Apr 15 '15 17:04

BassMHL


1 Answers

This is a great article on Angular app folder structure: https://scotch.io/tutorials/angularjs-best-practices-directory-structure

To answer your question about stuff like jQuery / bootstrap.js I would put them into a libs folder.

I use this methodology in all my apps now. For your Angular files the old way / way for small apps would probably have been this:

app/
----- controllers/
---------- mainController.js
---------- otherController.js
----- directives/
---------- mainDirective.js
---------- otherDirective.js
----- services/
---------- userService.js
---------- itemService.js
----- js/
---------- bootstrap.js
---------- jquery.js
----- app.js
views/
----- mainView.html
----- otherView.html
----- index.html

Better more efficient way (more descriptive as well):

app/
----- shared/   // acts as reusable components or partials of our site
---------- sidebar/
--------------- sidebarDirective.js
--------------- sidebarView.html
---------- article/
--------------- articleDirective.js
--------------- articleView.html
----- components/   // each component is treated as a mini Angular app
---------- home/
--------------- homeController.js
--------------- homeService.js
--------------- homeView.html
---------- blog/
--------------- blogController.js
--------------- blogService.js
--------------- blogView.html
----- app.module.js
----- app.routes.js
assets/
----- img/      // Images and icons for your app
----- css/      // All styles and style related files (SCSS or LESS files)
----- js/       // JavaScript files written for your app that are not for angular
----- libs/     // Third-party libraries such as jQuery, Moment, Underscore, etc.
index.html

What I'm using in my current project:
enter image description here

like image 192
Leon Gaban Avatar answered Oct 09 '22 09:10

Leon Gaban