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

Function getControllers

test/angular/1.6/angular.js:10127–10169  ·  view source on GitHub ↗
(directiveName, require, $element, elementControllers)

Source from the content-addressed store, hash-verified

10125 }
10126
10127 function getControllers(directiveName, require, $element, elementControllers) {
10128 var value;
10129
10130 if (isString(require)) {
10131 var match = require.match(REQUIRE_PREFIX_REGEXP);
10132 var name = require.substring(match[0].length);
10133 var inheritType = match[1] || match[3];
10134 var optional = match[2] === '?';
10135
10136 //If only parents then start at the parent element
10137 if (inheritType === '^^') {
10138 $element = $element.parent();
10139 //Otherwise attempt getting the controller from elementControllers in case
10140 //the element is transcluded (and has no data) and to avoid .data if possible
10141 } else {
10142 value = elementControllers && elementControllers[name];
10143 value = value && value.instance;
10144 }
10145
10146 if (!value) {
10147 var dataName = '$' + name + 'Controller';
10148 value = inheritType ? $element.inheritedData(dataName) : $element.data(dataName);
10149 }
10150
10151 if (!value && !optional) {
10152 throw $compileMinErr('ctreq',
10153 'Controller \'{0}\', required by directive \'{1}\', can\'t be found!',
10154 name, directiveName);
10155 }
10156 } else if (isArray(require)) {
10157 value = [];
10158 for (var i = 0, ii = require.length; i < ii; i++) {
10159 value[i] = getControllers(directiveName, require[i], $element, elementControllers);
10160 }
10161 } else if (isObject(require)) {
10162 value = {};
10163 forEach(require, function(controller, property) {
10164 value[property] = getControllers(directiveName, controller, $element, elementControllers);
10165 });
10166 }
10167
10168 return value || null;
10169 }
10170
10171 function setupControllers($element, attrs, transcludeFn, controllerDirectives, isolateScope, scope, newIsolateScopeDirective) {
10172 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