03. Angularjs Module and Controller

Source: Internet
Author: User

Most applications have a Main method (main) to organize, instantiate, and launch applications. The ANGULARJS application is not the main method, it is through the module to declare how the application should start. At the same time, the module allows declarations to describe dependencies in an application, and how to assemble and start:

1, ANGULARJS module is a framework of the organization business, in a module to define multiple services. When a module is introduced, it is possible to use one or more of the services provided by this module.

2, ANGULARJS itself a default module is the Ng,ng module provides $http, $scope and so on services.

3, the service is only one of the various mechanisms provided by ANGULARJS, the other is the instruction (Directive), filter (filer) and other configuration information.

4. In Angularjs, you can also define a service in an existing module, or you can define a module and then define a new service in the new module.

5. In Angularjs, the service is a declaration dependency (ingestion) relationship that needs to be displayed, allowing Ng to be automatically introduced into the service.

  

<! DOCTYPE html>

The above is how the module and the controller are defined. We define a module Ngapp using the Augularjs's module method, and the brackets [] indicate that the module is not dependent, and if there is a dependency, it will be written in brackets depending on the name of the module.

We use the Augularjs controller method to define a director Firstcontroller. Ng-app= "Ngapp" in the HTML page defines the control position of the module, while ng-controller= "Firstcontroller" defines the function area of the controller.

The sample code in this article runs with the following results:

  

03. Angularjs Module and Controller

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.