The AngularJS module configuration phase is executed when a module is being defined. During this phase, any providers are registered with the dependency injector. You should put only configuration and provider code inside the configuration block.
You implement the configuration block by calling the config()
method on the instance of the Module
object, using the following syntax:
config(function([injectable, . . .]))
A function with the injectable
parameters is passed in. The injectable
parameters are typically provider services functions such as $provide
.
The following is an example of a basic configuration block:
var myModule = angular.module('myModule', []).
config(function($provide, $filterProvider) {
$provide.value("startTime", new Date());
$filterProvider.register('myFilter', function(){});
});
Notice that the $provide
and $filterProvider
services are passed into the config
function. They are used to register a value provider named startTime
and a filter provider named myFilter
with the injector service.