@ The beast's angular Api learn, translate and understand--angular.module

Source: Internet
Author: User

@ The beast's NG API Learning--Angular.module

Angular.module

Create a global angular module that can be used for retrieval and injection. All angular modules (angular core modules or third-party modules) that want to be implemented in the application need to use this injection mechanism.

Format: Angular.module (NAME,[REQUIRES],[CONFIGFN]);

Name:string the name of the module created.

[requires]: An array of strings represents the list of other modules that the module depends on, or an empty array if no other modules are dependent.

[CONFIGFN]: Some configuration of the module.

Using code:

Angular.module ("Demo", ["Ui.router"],function () {//config})

Angular.module is to be written after the 1.3 version, @ Beast in just use angular download is 1.2.8 version, that will start when only need to write a ngapp on the DOM element of the root node, in JS can directly function a controller, and then in the corresponding Div write ng-controller on the good. After the 1.3 version, however, the module name must be defined and created with Angular.module.

It is important to note that the third parameter is seldom used, and he is in fact the same as. config (), so most of us use. config () to configure the module, so that the wording is relatively clear, and can be placed in other JS configuration, more convenient.

There is a second parameter, today online has a small partner asked me, why according to the use of a plug-in tutorial article said the Dependency injection module name of the plug-in will error said module name errors, for this problem, @ Beast here say, if you need to use a plug-in, but you do not know or unsure of his module name, You can open the JS code of the plugin to find Angular.module ("xxx"), this XXX is the module name you need to inject into your module ...

@ The beast's angular Api learn, translate and understand--angular.module

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.