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

Function getControllers

test/angular/1.3/angular.js:7574–7618  ·  view source on GitHub ↗
(directiveName, require, $element, elementControllers)

Source from the content-addressed store, hash-verified

7572
7573
7574 function getControllers(directiveName, require, $element, elementControllers) {
7575 var value, retrievalMethod = 'data', optional = false;
7576 var $searchElement = $element;
7577 var match;
7578 if (isString(require)) {
7579 match = require.match(REQUIRE_PREFIX_REGEXP);
7580 require = require.substring(match[0].length);
7581
7582 if (match[3]) {
7583 if (match[1]) match[3] = null;
7584 else match[1] = match[3];
7585 }
7586 if (match[1] === '^') {
7587 retrievalMethod = 'inheritedData';
7588 } else if (match[1] === '^^') {
7589 retrievalMethod = 'inheritedData';
7590 $searchElement = $element.parent();
7591 }
7592 if (match[2] === '?') {
7593 optional = true;
7594 }
7595
7596 value = null;
7597
7598 if (elementControllers && retrievalMethod === 'data') {
7599 if (value = elementControllers[require]) {
7600 value = value.instance;
7601 }
7602 }
7603 value = value || $searchElement[retrievalMethod]('$' + require + 'Controller');
7604
7605 if (!value && !optional) {
7606 throw $compileMinErr('ctreq',
7607 "Controller '{0}', required by directive '{1}', can't be found!",
7608 require, directiveName);
7609 }
7610 return value || null;
7611 } else if (isArray(require)) {
7612 value = [];
7613 forEach(require, function(require) {
7614 value.push(getControllers(directiveName, require, $element, elementControllers));
7615 });
7616 }
7617 return value;
7618 }
7619
7620
7621 function nodeLinkFn(childLinkFn, scope, linkNode, $rootElement, boundTranscludeFn) {

Callers 1

nodeLinkFnFunction · 0.70

Calls 4

isArrayFunction · 0.85
matchMethod · 0.80
isStringFunction · 0.70
forEachFunction · 0.70

Tested by

no test coverage detected