AngularJs (vii) Creation of modules

Source: Internet
Author: User

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:

    

Create

var 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);        });
Reference
var app = Angular.module ("Exampleapp");

The above indicates that Exampleapp's module has been created, and when this code appears, ANGULARJS will find the module.

Summary

when 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.