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

Function getControllers

test/angular/1.5/angular.js:9607–9649  ·  view source on GitHub ↗
(directiveName, require, $element, elementControllers)

Source from the content-addressed store, hash-verified

9605 }
9606
9607 function getControllers(directiveName, require, $element, elementControllers) {
9608 var value;
9609
9610 if (isString(require)) {
9611 var match = require.match(REQUIRE_PREFIX_REGEXP);
9612 var name = require.substring(match[0].length);
9613 var inheritType = match[1] || match[3];
9614 var optional = match[2] === '?';
9615
9616 //If only parents then start at the parent element
9617 if (inheritType === '^^') {
9618 $element = $element.parent();
9619 //Otherwise attempt getting the controller from elementControllers in case
9620 //the element is transcluded (and has no data) and to avoid .data if possible
9621 } else {
9622 value = elementControllers && elementControllers[name];
9623 value = value && value.instance;
9624 }
9625
9626 if (!value) {
9627 var dataName = '$' + name + 'Controller';
9628 value = inheritType ? $element.inheritedData(dataName) : $element.data(dataName);
9629 }
9630
9631 if (!value && !optional) {
9632 throw $compileMinErr('ctreq',
9633 'Controller \'{0}\', required by directive \'{1}\', can\'t be found!',
9634 name, directiveName);
9635 }
9636 } else if (isArray(require)) {
9637 value = [];
9638 for (var i = 0, ii = require.length; i < ii; i++) {
9639 value[i] = getControllers(directiveName, require[i], $element, elementControllers);
9640 }
9641 } else if (isObject(require)) {
9642 value = {};
9643 forEach(require, function(controller, property) {
9644 value[property] = getControllers(directiveName, controller, $element, elementControllers);
9645 });
9646 }
9647
9648 return value || null;
9649 }
9650
9651 function setupControllers($element, attrs, transcludeFn, controllerDirectives, isolateScope, scope, newIsolateScopeDirective) {
9652 var elementControllers = createMap();

Callers 1

nodeLinkFnFunction · 0.70

Calls 5

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

Tested by

no test coverage detected