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

Function $ControllerProvider

lib/test/angular/1.8.0/angular.js:11661–11806  ·  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

11659 * {@link ng.$controllerProvider#register register} method.
11660 */
11661function $ControllerProvider() {
11662 var controllers = {};
11663
11664 /**
11665 * @ngdoc method
11666 * @name $controllerProvider#has
11667 * @param {string} name Controller name to check.
11668 */
11669 this.has = function(name) {
11670 return controllers.hasOwnProperty(name);
11671 };
11672
11673 /**
11674 * @ngdoc method
11675 * @name $controllerProvider#register
11676 * @param {string|Object} name Controller name, or an object map of controllers where the keys are
11677 * the names and the values are the constructors.
11678 * @param {Function|Array} constructor Controller constructor fn (optionally decorated with DI
11679 * annotations in the array notation).
11680 */
11681 this.register = function(name, constructor) {
11682 assertNotHasOwnProperty(name, 'controller');
11683 if (isObject(name)) {
11684 extend(controllers, name);
11685 } else {
11686 controllers[name] = constructor;
11687 }
11688 };
11689
11690 this.$get = ['$injector', function($injector) {
11691
11692 /**
11693 * @ngdoc service
11694 * @name $controller
11695 * @requires $injector
11696 *
11697 * @param {Function|string} constructor If called with a function then it's considered to be the
11698 * controller constructor function. Otherwise it's considered to be a string which is used
11699 * to retrieve the controller constructor using the following steps:
11700 *
11701 * * check if a controller with given name is registered via `$controllerProvider`
11702 * * check if evaluating the string on the current scope returns a constructor
11703 *
11704 * The string can use the `controller as property` syntax, where the controller instance is published
11705 * as the specified property on the `scope`; the `scope` must be injected into `locals` param for this
11706 * to work correctly.
11707 *
11708 * @param {Object} locals Injection locals for Controller.
11709 * @return {Object} Instance of given controller.
11710 *
11711 * @description
11712 * `$controller` service is responsible for instantiating controllers.
11713 *
11714 * It's just a simple call to {@link auto.$injector $injector}, but extracted into
11715 * a service, so that one can override this service with [BC version](https://gist.github.com/1649788).
11716 */
11717 return function $controller(expression, locals, later, ident) {
11718 // 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