javascript - why define multiple module with same name in angularjs -


i new @ angularjs. looking application code.

<html>   ..... <script src="/my/app.main.js"></script> <script src="/my/app.messages.js"></script> <script src="/my/app.misc.js"></script> <script src="/my/app.properties.js"></script> 

and in these javascript filse icluding angularjs modules same name.

main.js file

(function () {     'use strict';      var app = angular.module('ngcookservice');      app.run([.....         function (....) {                      }]); })(); 

messages.js file

(function () {     "use strict";      var app = angular.module('ngcookservice');      app.config(['$stateprovider', function ($stateprovider) {         ................     }]); })(); 

all of these js files include ngcookservice module. , modules defined in self-invoking functions.

how system works? earlier defined modules overriding? or new defined app module kills earlier objects?

when called name of module, angular.module() getter method , retrieves existing module name. therefore calling angular.module('ngcookservice') not override or replace module.

for getter work, somewhere before setter must have been called. done calling angular.module() more 1 argument (for example, list of required modules)...

angular.module('ngcookservice', ['ngroute']); 

if setter called more once, module is being overridden.


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -