Angular Application Folder Structure

Angular Application Folder Structure

Today, We want to share with you Angular Application Folder Structure.
In this post we will show you AngularJs Application Folder Structure, hear for AngularJs Application Structure we will give you demo and example for implement.
In this post, we will learn about AngularJS Folder Structure with an example.

Simple Way AngularJS – Directory Structure for Angular Apps

I shall cover best practices to perfect regarding directory(folder) structures for both small-apps and large-apps AngularJS application.

We have a parts – separation of concerns parts like controllers,modules,views, controllers specific have their own folder all the controllers, views have their add on own folder(partial), external libraries have theiradd on own folder(dir.), etc.

READ :  Angularjs push object into array first index - angularjs unshift Examples

imp points Once you have more than 12 or more controllers, services,views(partial,tpl) and directives so, you are going to all files have to do a lot of all the scrolling in your project directory(folder) tree to find the must required files.

second things, An ideal AngularJS application structure should be different types of module(ng-app) modularized into best specific functions.

Goals – why structure?

The Main goals I want for any application or project structure are:

*)There must be consistency in the File structure in your project
*)we must be able to find what we are looking for quickly and fast.
*)I must be able to find all the php we are looking for based on file names and file location
*)It has to scale

READ :  Validating Woocommerce webhook using HMAC in PHP

Angularjs File : Naming convention List

One of the first best things you must be notice is that we have a any very strict (special )naming convention for application files:

1st)The Controllers – [FileName].ctrl.js
2nd)The Templates-[FileName].tpl.html
3rd)The Directives-[FileName].drct.js
4th)The Factories-[FileName].fct.js
5th)The Values-[FileName].val.js
6th)The Services-[FileName].srv.js
7th)The Modules-[apps_name].[modules_name].js

Simple AngularJS Project Structure

->index.html (or index.php)
->/resources
–>/css
–>/fonts
–>/images
–>/js
—>/controllers
—>/directives
—>/filters
—>/services
–>/partials (views pages)

Standard Structure in angularjs

[php]

root-application-folder(root folder Like cricmaster)
β”œβ”€β”€ index.html or index.php
β”œβ”€β”€ scripts(js files)
β”‚ β”œβ”€β”€ controllers(AngularJS controllers)
β”‚ β”‚ └── main.js(routing files)
β”‚ β”‚ └── …
β”‚ β”œβ”€β”€ directives(AngularJS directives)
β”‚ β”‚ └── myDirective.js
β”‚ β”‚ └── …
β”‚ β”œβ”€β”€ filters(AngularJS filters)
β”‚ β”‚ └── myFilter.js
β”‚ β”‚ └── …
β”‚ β”œβ”€β”€ services(AngularJS services)
β”‚ β”‚ └── myService.js
β”‚ β”‚ └── …
β”‚ β”œβ”€β”€ vendor(AngularJS libs)
β”‚ β”‚ β”œβ”€β”€ angular.js(basic js)
β”‚ β”‚ β”œβ”€β”€ angular.min.js(minify js)
β”‚ β”‚ β”œβ”€β”€ es5-shim.min.js
β”‚ β”‚ └── json3.min.js
β”‚ └── app.js(routing js libs)
β”œβ”€β”€ styles(css external files)
β”‚ └── …
└── views(partials or templates)
β”œβ”€β”€ main.html(index.html)
└── …

READ :  vuejs Authentication - vue sessionstorage and localstorage

[/php]

Directory Structure in angularJs

[php]
app/
—– controllers/
———- homeController.js
———- conatctController.js
———- mainController.js
———- productController.js
———- aboutController.js
———- otherController.js
—– directives/
———- homeDirective.js
———- conatctDirective.js
———- mainDirective.js
———- otherDirective.js
———- aboutusDirective.js
—– services/
———- loginService.js
———- registerService.js
———- itemService.js
———- userService.js
———- checkoutService.js
—– js/
———- custom.js
———- bootstrap.js
———- validation.js
———- jquery.js
———- logicdata.js
—– app.js
views/
—– home.html
—– contact.html
—– mainView.html
—– about.html
—– salesorder.html
—– otherView.html
—– index.html or index.php

[/php]

Leave a Comment