AngularJS app.module vs app.route -


i read article best practices angularjs project structure: https://scotch.io/tutorials/angularjs-best-practices-directory-structure

under title "app folder" explains shortly difference between files app.module.js , app.route.js didn't understand.

can give me example short pseudo code both of files?

any profoundly appreciated!

under structure, app.module.js used create main module application (eg. app), configure services using throughout application, or running arbitrary code once module has loaded of dependencies , configured services may wish configure.

app.route.js configuring 1 service: router using handle state in application. create own module or re-use 1 app.module.js, if use custom module, have depend on choice of router directly. in addition, have add dependency main app.module.js eg.

angular.module('app', ['app.routes']);

angular.module('app.routes', ['routermodule']);

example using 1 module named app, depends on other arbitrary module somemodule , routing module routermodule:

app.module.js

angular.module('app', ['somemodule', 'routermodule'])   .config(function (someserviceprovider, someotherserviceprovider) {     // configure someserviceprovider/someotherserviceprovider.   })   .run(function () {     console.log('done loading dependencies , configuring module!');   }); 

app.route.js

angular.module('app')   .config(function (yourrouterprovider) {     // configure yourrouterprovider define states application.   }); 

angular modules:

https://docs.angularjs.org/api/ng/function/angular.module

routing in angular using ngrouter:

https://docs.angularjs.org/api/ngroute


Comments

Popular posts from this blog

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

Making Empty C++ Project: General exception (Exception from HRESULT:0x80131500) Visual Studio Community 2015 -

How to fix java warning for "The value of the local variable is not used " -