Interface for configuring AngularJS modules.
info([info]);
Read and write custom information about this module. For example you could put the version of the module in here.
angular.module('myModule', []).info({ version: '1.0.0' });
The version could then be read back out by accessing the module elsewhere:
var version = angular.module('myModule').info().version;
You can also retrieve this information during runtime via the
$injector.modules property:
var version = $injector.modules['myModule'].info().version;
| Param | Type | Details |
|---|---|---|
|
info
(optional)
|
Object |
Information about the module |
| ObjectModule | The current info object for this module if called as a getter,
or |
provider(name, providerType);
See $provide.provider().
| Param | Type | Details |
|---|---|---|
| name | string |
service name |
| providerType | Function |
Construction function for creating new instance of the service. |
factory(name, providerFunction);
See $provide.factory().
| Param | Type | Details |
|---|---|---|
| name | string |
service name |
| providerFunction | Function |
Function for creating new instance of the service. |
service(name, constructor);
See $provide.service().
| Param | Type | Details |
|---|---|---|
| name | string |
service name |
| constructor | Function |
A constructor function that will be instantiated. |
value(name, object);
See $provide.value().
| Param | Type | Details |
|---|---|---|
| name | string |
service name |
| object | * |
Service instance object. |
constant(name, object);
Because the constants are fixed, they get applied before other provide methods. See $provide.constant().
| Param | Type | Details |
|---|---|---|
| name | string |
constant name |
| object | * |
Constant value. |
decorator(name, decorFn);
See $provide.decorator().
| Param | Type | Details |
|---|---|---|
| name | string |
The name of the service to decorate. |
| decorFn | Function |
This function will be invoked when the service needs to be instantiated and should return the decorated service instance. |
animation(name, animationFactory);
NOTE: animations take effect only if the ngAnimate module is loaded.
Defines an animation hook that can be later used with $animate service and directives that use this service.
module.animation('.animation-name', function($inject1, $inject2) {
return {
eventName : function(element, done) {
//code to run the animation
//once complete, then run done()
return function cancellationFunction(element) {
//code to cancel the animation
}
}
}
})
See $animateProvider.register() and ngAnimate module for more information.
| Param | Type | Details |
|---|---|---|
| name | string |
animation name |
| animationFactory | Function |
Factory function for creating new instance of an animation. |
filter(name, filterFactory);
See $filterProvider.register().
Expressions identifiers, such as uppercase or orderBy.
Names with special characters, such as hyphens and dots, are not allowed. If you wish to namespace
your filters, then you can use capitalization (myappSubsectionFilterx) or underscores
(myapp_subsection_filterx).
| Param | Type | Details |
|---|---|---|
| name | string |
Filter name - this must be a valid AngularJS expression identifier |
| filterFactory | Function |
Factory function for creating new instance of filter. |
controller(name, constructor);
| Param | Type | Details |
|---|---|---|
| name | stringObject |
Controller name, or an object map of controllers where the keys are the names and the values are the constructors. |
| constructor | Function |
Controller constructor function. |
directive(name, directiveFactory);
| Param | Type | Details |
|---|---|---|
| name | stringObject |
Directive name, or an object map of directives where the keys are the names and the values are the factories. |
| directiveFactory | Function |
Factory function for creating new instance of directives. |
component(name, options);
| Param | Type | Details |
|---|---|---|
| name | stringObject |
Name of the component in camelCase (i.e. |
| options | Object |
Component definition object (a simplified directive definition object) |
config(configFn);
Use this method to configure services by injecting their
providers, e.g. for adding routes to the
$routeProvider.
Note that you can only inject providers and
constants into this function.
For more about how to configure services, see Provider Recipe.
| Param | Type | Details |
|---|---|---|
| configFn | Function |
Execute this function on module load. Useful for service configuration. |
run(initializationFn);
Use this method to register work which should be performed when the injector is done loading all modules.
| Param | Type | Details |
|---|---|---|
| initializationFn | Function |
Execute this function after injector creation. Useful for application initialization. |
requiresHolds the list of modules which the injector will load before the current module is loaded. |
nameName of the module. |