Improve this Doc View Source angular.module

From Get docs
< Function components in ngAngularjs/docs/1.8/api/ng/function/angular.module

Improve this Doc View Source angular.module

  1. function in module ng


The angular.module is a global place for creating, registering and retrieving AngularJS modules. All modules (AngularJS core or 3rd party) that should be available to an application must be registered using this mechanism.

Passing one argument retrieves an existing angular.Module, whereas passing more than one argument creates a new angular.Module


A module is a collection of services, directives, controllers, filters, and configuration information. angular.module is used to configure the $injector.

// Create a new module
var myModule = angular.module('myModule', []);

// register a new service
myModule.value('appName', 'MyCoolApp');

// configure existing services inside initialization blocks.
myModule.config(['$locationProvider', function($locationProvider) {
  // Configure existing providers

Then you can create an injector and load your modules like this:

var injector = angular.injector(['ng', 'myModule'])

However it's more likely that you'll just use ngApp or angular.bootstrap to simplify this process for you.


angular.module(name, [requires], [configFn]);


Param Type Details
name string The name of the module to create or retrieve.



!Array.<string>= If specified then new module is being created. If unspecified then the module is being retrieved for further configuration.



Function= Optional configuration function for the module. Same as Module#config().


angular.Module new module with the angular.Module api.

© 2010–2020 Google, Inc.
Licensed under the Creative Commons Attribution License 3.0.