MCPcopy Index your code
hub / github.com/angular-ui/ui-router / $ControllerProvider

Function $ControllerProvider

test/angular/1.5/angular.js:10461–10626  ·  view source on GitHub ↗

* @ngdoc provider * @name $controllerProvider * @this * * @description * The ng.$controller $controller service is used by Angular to create new * controllers. * * This provider allows controller registration via the * ng.$controllerProvider#register register method.

()

Source from the content-addressed store, hash-verified

10459 * {@link ng.$controllerProvider#register register} method.
10460 */
10461function $ControllerProvider() {
10462 var controllers = {},
10463 globals = false;
10464
10465 /**
10466 * @ngdoc method
10467 * @name $controllerProvider#has
10468 * @param {string} name Controller name to check.
10469 */
10470 this.has = function(name) {
10471 return controllers.hasOwnProperty(name);
10472 };
10473
10474 /**
10475 * @ngdoc method
10476 * @name $controllerProvider#register
10477 * @param {string|Object} name Controller name, or an object map of controllers where the keys are
10478 * the names and the values are the constructors.
10479 * @param {Function|Array} constructor Controller constructor fn (optionally decorated with DI
10480 * annotations in the array notation).
10481 */
10482 this.register = function(name, constructor) {
10483 assertNotHasOwnProperty(name, 'controller');
10484 if (isObject(name)) {
10485 extend(controllers, name);
10486 } else {
10487 controllers[name] = constructor;
10488 }
10489 };
10490
10491 /**
10492 * @ngdoc method
10493 * @name $controllerProvider#allowGlobals
10494 *
10495 * @deprecated
10496 * sinceVersion="v1.3.0"
10497 * removeVersion="v1.7.0"
10498 * This method of finding controllers has been deprecated.
10499 *
10500 * @description If called, allows `$controller` to find controller constructors on `window` *
10501 */
10502 this.allowGlobals = function() {
10503 globals = true;
10504 };
10505
10506
10507 this.$get = ['$injector', '$window', function($injector, $window) {
10508
10509 /**
10510 * @ngdoc service
10511 * @name $controller
10512 * @requires $injector
10513 *
10514 * @param {Function|string} constructor If called with a function then it's considered to be the
10515 * controller constructor function. Otherwise it's considered to be a string which is used
10516 * to retrieve the controller constructor using the following steps:
10517 *
10518 * * check if a controller with given name is registered via `$controllerProvider`

Callers

nothing calls this directly

Calls 10

isArrayFunction · 0.85
matchMethod · 0.80
assertNotHasOwnPropertyFunction · 0.70
isObjectFunction · 0.70
extendFunction · 0.70
isStringFunction · 0.70
getterFunction · 0.70
assertArgFnFunction · 0.70
addIdentifierFunction · 0.70
isFunctionFunction · 0.70

Tested by

no test coverage detected