MCPcopy
hub / github.com/angular-ui/ui-router / setupModuleLoader

Function setupModuleLoader

test/angular/1.2/angular.js:1597–1898  ·  view source on GitHub ↗

* @ngdoc type * @name angular.Module * @module ng * @description * * Interface for configuring angular angular.module modules.

(window)

Source from the content-addressed store, hash-verified

1595 */
1596
1597function setupModuleLoader(window) {
1598
1599 var $injectorMinErr = minErr('$injector');
1600 var ngMinErr = minErr('ng');
1601
1602 function ensure(obj, name, factory) {
1603 return obj[name] || (obj[name] = factory());
1604 }
1605
1606 var angular = ensure(window, 'angular', Object);
1607
1608 // We need to expose `angular.$$minErr` to modules such as `ngResource` that reference it during bootstrap
1609 angular.$$minErr = angular.$$minErr || minErr;
1610
1611 return ensure(angular, 'module', function() {
1612 /** @type {Object.<string, angular.Module>} */
1613 var modules = {};
1614
1615 /**
1616 * @ngdoc function
1617 * @name angular.module
1618 * @module ng
1619 * @description
1620 *
1621 * The `angular.module` is a global place for creating, registering and retrieving Angular
1622 * modules.
1623 * All modules (angular core or 3rd party) that should be available to an application must be
1624 * registered using this mechanism.
1625 *
1626 * When passed two or more arguments, a new module is created. If passed only one argument, an
1627 * existing module (the name passed as the first argument to `module`) is retrieved.
1628 *
1629 *
1630 * # Module
1631 *
1632 * A module is a collection of services, directives, controllers, filters, and configuration information.
1633 * `angular.module` is used to configure the {@link auto.$injector $injector}.
1634 *
1635 * ```js
1636 * // Create a new module
1637 * var myModule = angular.module('myModule', []);
1638 *
1639 * // register a new service
1640 * myModule.value('appName', 'MyCoolApp');
1641 *
1642 * // configure existing services inside initialization blocks.
1643 * myModule.config(['$locationProvider', function($locationProvider) {
1644 * // Configure existing providers
1645 * $locationProvider.hashPrefix('!');
1646 * }]);
1647 * ```
1648 *
1649 * Then you can create an injector and load your modules like this:
1650 *
1651 * ```js
1652 * var injector = angular.injector(['ng', 'myModule'])
1653 * ```
1654 *

Callers 1

publishExternalAPIFunction · 0.70

Calls 4

minErrFunction · 0.70
ensureFunction · 0.70
assertNotHasOwnPropertyFunction · 0.70
invokeLaterFunction · 0.70

Tested by

no test coverage detected