MCPcopy
hub / github.com/angular-ui/ui-grid / $ControllerProvider

Function $ControllerProvider

lib/test/angular/1.7.0/angular.js:11027–11172  ·  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

11025 * {@link ng.$controllerProvider#register register} method.
11026 */
11027function $ControllerProvider() {
11028 var controllers = {};
11029
11030 /**
11031 * @ngdoc method
11032 * @name $controllerProvider#has
11033 * @param {string} name Controller name to check.
11034 */
11035 this.has = function(name) {
11036 return controllers.hasOwnProperty(name);
11037 };
11038
11039 /**
11040 * @ngdoc method
11041 * @name $controllerProvider#register
11042 * @param {string|Object} name Controller name, or an object map of controllers where the keys are
11043 * the names and the values are the constructors.
11044 * @param {Function|Array} constructor Controller constructor fn (optionally decorated with DI
11045 * annotations in the array notation).
11046 */
11047 this.register = function(name, constructor) {
11048 assertNotHasOwnProperty(name, 'controller');
11049 if (isObject(name)) {
11050 extend(controllers, name);
11051 } else {
11052 controllers[name] = constructor;
11053 }
11054 };
11055
11056 this.$get = ['$injector', function($injector) {
11057
11058 /**
11059 * @ngdoc service
11060 * @name $controller
11061 * @requires $injector
11062 *
11063 * @param {Function|string} constructor If called with a function then it's considered to be the
11064 * controller constructor function. Otherwise it's considered to be a string which is used
11065 * to retrieve the controller constructor using the following steps:
11066 *
11067 * * check if a controller with given name is registered via `$controllerProvider`
11068 * * check if evaluating the string on the current scope returns a constructor
11069 *
11070 * The string can use the `controller as property` syntax, where the controller instance is published
11071 * as the specified property on the `scope`; the `scope` must be injected into `locals` param for this
11072 * to work correctly.
11073 *
11074 * @param {Object} locals Injection locals for Controller.
11075 * @return {Object} Instance of given controller.
11076 *
11077 * @description
11078 * `$controller` service is responsible for instantiating controllers.
11079 *
11080 * It's just a simple call to {@link auto.$injector $injector}, but extracted into
11081 * a service, so that one can override this service with [BC version](https://gist.github.com/1649788).
11082 */
11083 return function $controller(expression, locals, later, ident) {
11084 // PRIVATE API:

Callers

nothing calls this directly

Calls 9

assertNotHasOwnPropertyFunction · 0.70
isObjectFunction · 0.70
extendFunction · 0.70
isStringFunction · 0.70
getterFunction · 0.70
assertArgFnFunction · 0.70
isArrayFunction · 0.70
addIdentifierFunction · 0.70
isFunctionFunction · 0.70

Tested by

no test coverage detected