MCPcopy Index your code
hub / github.com/angular-ui/ui-grid / getControllers

Function getControllers

lib/test/angular/1.4.3/angular.js:7982–8019  ·  view source on GitHub ↗
(directiveName, require, $element, elementControllers)

Source from the content-addressed store, hash-verified

7980
7981
7982 function getControllers(directiveName, require, $element, elementControllers) {
7983 var value;
7984
7985 if (isString(require)) {
7986 var match = require.match(REQUIRE_PREFIX_REGEXP);
7987 var name = require.substring(match[0].length);
7988 var inheritType = match[1] || match[3];
7989 var optional = match[2] === '?';
7990
7991 //If only parents then start at the parent element
7992 if (inheritType === '^^') {
7993 $element = $element.parent();
7994 //Otherwise attempt getting the controller from elementControllers in case
7995 //the element is transcluded (and has no data) and to avoid .data if possible
7996 } else {
7997 value = elementControllers && elementControllers[name];
7998 value = value && value.instance;
7999 }
8000
8001 if (!value) {
8002 var dataName = '$' + name + 'Controller';
8003 value = inheritType ? $element.inheritedData(dataName) : $element.data(dataName);
8004 }
8005
8006 if (!value && !optional) {
8007 throw $compileMinErr('ctreq',
8008 "Controller '{0}', required by directive '{1}', can't be found!",
8009 name, directiveName);
8010 }
8011 } else if (isArray(require)) {
8012 value = [];
8013 for (var i = 0, ii = require.length; i < ii; i++) {
8014 value[i] = getControllers(directiveName, require[i], $element, elementControllers);
8015 }
8016 }
8017
8018 return value || null;
8019 }
8020
8021 function setupControllers($element, attrs, transcludeFn, controllerDirectives, isolateScope, scope) {
8022 var elementControllers = createMap();

Callers 1

nodeLinkFnFunction · 0.70

Calls 2

isStringFunction · 0.70
isArrayFunction · 0.50

Tested by

no test coverage detected