Module
At present I choose to write in the AngularJs-1.5 version, if in doubt can contact me.
Understand the life cycle of the module.
The config and run methods are the methods that are loaded when the module is called. So what's the order of the module's execution?
The Config method is the method that is called after the module is loaded. The Run method is the method that is called after all the modules have been loaded.
<! DOCTYPE html>Operation Result:
Createvar app = Angular.module ("Exampleapp", ["exampleapp.services"]);
The module function consists of three parameters (Name,requires,config);
Name: Indicates the names of the modules to be created such as: Exampleapp;
Requires: Represents the name of the module on which it was created.
Config: A function that represents the registration of a module callback. Equivalent to app. config ();
var app = Angular.module ("Exampleapp", ["exampleapp.services"], function (startTime) { console.log ("Main module Config: "+ startTime); });
Referencevar app = Angular.module ("Exampleapp");
The above indicates that Exampleapp's module has been created, and when this code appears, ANGULARJS will find the module.
Summarywhen using a module, ANGULARJS guarantees that the callback function of the module on which the main module depends is parsed first. Because the Run method is executed after all the modules have been loaded. All, when the config of the dependent module is parsed, wait until all the modules are loaded, execute the dependent run method, and finally the main module's Run method.
AngularJs (vii) Creation of modules