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

Function getControllers

test/angular/1.4/angular.js:8427–8464  ·  view source on GitHub ↗
(directiveName, require, $element, elementControllers)

Source from the content-addressed store, hash-verified

8425
8426
8427 function getControllers(directiveName, require, $element, elementControllers) {
8428 var value;
8429
8430 if (isString(require)) {
8431 var match = require.match(REQUIRE_PREFIX_REGEXP);
8432 var name = require.substring(match[0].length);
8433 var inheritType = match[1] || match[3];
8434 var optional = match[2] === '?';
8435
8436 //If only parents then start at the parent element
8437 if (inheritType === '^^') {
8438 $element = $element.parent();
8439 //Otherwise attempt getting the controller from elementControllers in case
8440 //the element is transcluded (and has no data) and to avoid .data if possible
8441 } else {
8442 value = elementControllers && elementControllers[name];
8443 value = value && value.instance;
8444 }
8445
8446 if (!value) {
8447 var dataName = '$' + name + 'Controller';
8448 value = inheritType ? $element.inheritedData(dataName) : $element.data(dataName);
8449 }
8450
8451 if (!value && !optional) {
8452 throw $compileMinErr('ctreq',
8453 "Controller '{0}', required by directive '{1}', can't be found!",
8454 name, directiveName);
8455 }
8456 } else if (isArray(require)) {
8457 value = [];
8458 for (var i = 0, ii = require.length; i < ii; i++) {
8459 value[i] = getControllers(directiveName, require[i], $element, elementControllers);
8460 }
8461 }
8462
8463 return value || null;
8464 }
8465
8466 function setupControllers($element, attrs, transcludeFn, controllerDirectives, isolateScope, scope) {
8467 var elementControllers = createMap();

Callers 1

nodeLinkFnFunction · 0.70

Calls 3

isArrayFunction · 0.85
matchMethod · 0.80
isStringFunction · 0.70

Tested by

no test coverage detected