ANGULARJS Module--Understanding Summary

Source: Internet
Author: User

In JS, it is unwise to define all of the function code in the global namespace.

In angular, the controller code is encapsulated in the module unit.

In Angularjs, the module is the most important way to define the application, the module contains the main application code,

An application can contain multiple modules, each containing code that defines the specific functionality.

A bit of using the module: 1. You can keep the global namespace clean

2. Apps can load sections of code in any order

Angularjs in the Declaration module: angular.module (name,requires),

The Angular.module () method accepts 2 parameters: the first name (string) is the module

The second require (string array) is a dependency list, a list of string variables, and each element in the list is the name of a module.

This module relies on these modules, which require pre-loading by the injector before the module is loaded.

Use of the Angular.module () method:

1. Angular.module (' myApp ', []); Equivalent to the setter method of the angular module, which defines the module.

2. Angular.module (' myApp '); When passing only one parameter, you can use it to refer to the module, which is equivalent to the getter method of the Angularjs module, which is used to obtain a reference to the module.

ANGULARJS Module--Understanding Summary

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.