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

Function $ControllerProvider

test/angular/1.6/angular.js:11009–11173  ·  view source on GitHub ↗

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

()

Source from the content-addressed store, hash-verified

11007 * {@link ng.$controllerProvider#register register} method.
11008 */
11009function $ControllerProvider() {
11010 var controllers = {},
11011 globals = false;
11012
11013 /**
11014 * @ngdoc method
11015 * @name $controllerProvider#has
11016 * @param {string} name Controller name to check.
11017 */
11018 this.has = function(name) {
11019 return controllers.hasOwnProperty(name);
11020 };
11021
11022 /**
11023 * @ngdoc method
11024 * @name $controllerProvider#register
11025 * @param {string|Object} name Controller name, or an object map of controllers where the keys are
11026 * the names and the values are the constructors.
11027 * @param {Function|Array} constructor Controller constructor fn (optionally decorated with DI
11028 * annotations in the array notation).
11029 */
11030 this.register = function(name, constructor) {
11031 assertNotHasOwnProperty(name, 'controller');
11032 if (isObject(name)) {
11033 extend(controllers, name);
11034 } else {
11035 controllers[name] = constructor;
11036 }
11037 };
11038
11039 /**
11040 * @ngdoc method
11041 * @name $controllerProvider#allowGlobals
11042 * @description If called, allows `$controller` to find controller constructors on `window`
11043 *
11044 * @deprecated
11045 * sinceVersion="v1.3.0"
11046 * removeVersion="v1.7.0"
11047 * This method of finding controllers has been deprecated.
11048 */
11049 this.allowGlobals = function() {
11050 globals = true;
11051 };
11052
11053
11054 this.$get = ['$injector', '$window', function($injector, $window) {
11055
11056 /**
11057 * @ngdoc service
11058 * @name $controller
11059 * @requires $injector
11060 *
11061 * @param {Function|string} constructor If called with a function then it's considered to be the
11062 * controller constructor function. Otherwise it's considered to be a string which is used
11063 * to retrieve the controller constructor using the following steps:
11064 *
11065 * * check if a controller with given name is registered via `$controllerProvider`
11066 * * check if evaluating the string on the current scope returns a constructor

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