Overview
A
module is a set of services, directives, controllers and filters plus some configuration information.
Most applications have a main method, which bootstraps the application.
In contrast, Angular uses modules to declaratively specify how the application should be bootstrapped.
Modules can be used to break an application up into functional sections.
For example, services, directives, controllers and filters that are specific to a particular application can be added to the application module.
Reusable directives can be added to a common directives module. Likewise, reusable services and domain models can be added to a common services module.
The
angular.module is a global place for creating and registering Angular modules.
All modules (angular core or 3rd-party) that need to be available to an application must be registered using this mechanism.
-
- var myModule = angular.module('myModule', []);
Key Modules
- ng: The main module (core functionality).
- ngMock: Adds unit-test configuration and mocks to the $injector.
- AUTO: Implicit module automatically added to each $injector.
- ngSanitize: Purges unwanted HTML tags from source strings.
- ngMobile: Mobile helpers, including support for touch events (based on jQuery Mobile touch event handling).
The ng Module
The
ng module contains Angular's core directives, filters, services and types:
- Directives (e.g., ngApp, ngBind, ngController, ngModel)
- Filters (e.g., currency, date, json)
- Services (e.g., $compile, $controller, $log, $route)
- Types (e.g., Module, Scope)
- Global APIs (e.g., angular.bind, angular.element)