On this page
Improve this Doc View Source angular.Module
- type in module ng
Overview
Interface for configuring AngularJS modules.
Methods
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.modulesproperty:var version = $injector.modules['myModule'].info().version;Parameters
Param Type Details info (optional)ObjectInformation about the module
Returns
ObjectModuleThe current info object for this module if called as a getter, or
thisif called as a setter.provider(name, providerType);
See $provide.provider().
Parameters
Param Type Details name stringservice name
providerType FunctionConstruction function for creating new instance of the service.
factory(name, providerFunction);
See $provide.factory().
Parameters
Param Type Details name stringservice name
providerFunction FunctionFunction for creating new instance of the service.
service(name, constructor);
See $provide.service().
Parameters
Param Type Details name stringservice name
constructor FunctionA constructor function that will be instantiated.
value(name, object);
See $provide.value().
Parameters
Param Type Details name stringservice name
object *Service instance object.
constant(name, object);
Because the constants are fixed, they get applied before other provide methods. See $provide.constant().
Parameters
Param Type Details name stringconstant name
object *Constant value.
decorator(name, decorFn);
See $provide.decorator().
Parameters
Param Type Details name stringThe name of the service to decorate.
decorFn FunctionThis 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.
Parameters
Param Type Details name stringanimation name
animationFactory FunctionFactory function for creating new instance of an animation.
filter(name, filterFactory);
See $filterProvider.register().
Note: Filter names must be valid AngularJSExpressionsidentifiers, such asuppercaseororderBy. 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).Parameters
Param Type Details name stringFilter name - this must be a valid AngularJS expression identifier
filterFactory FunctionFactory function for creating new instance of filter.
controller(name, constructor);
Parameters
Param Type Details name stringObjectController name, or an object map of controllers where the keys are the names and the values are the constructors.
constructor FunctionController constructor function.
directive(name, directiveFactory);
Parameters
Param Type Details name stringObjectDirective name, or an object map of directives where the keys are the names and the values are the factories.
directiveFactory FunctionFactory function for creating new instance of directives.
component(name, options);
Parameters
Param Type Details name stringName of the component in camel-case (i.e. myComp which will match as my-comp)
options ObjectComponent 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
providersandconstantsinto this function.For more about how to configure services, see Provider Recipe.
Parameters
Param Type Details configFn FunctionExecute 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.
Parameters
Param Type Details initializationFn FunctionExecute this function after injector creation. Useful for application initialization.
Properties
requires
Holds the list of modules which the injector will load before the current module is loaded.
name
Name of the module.
© 2010–2018 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://code.angularjs.org/1.6.9/docs/api/ng/type/angular.Module