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