MCPcopy
hub / github.com/angular-ui/ui-grid / getControllers

Function getControllers

lib/test/angular/1.7.0/angular.js:10133–10175  ·  view source on GitHub ↗
(directiveName, require, $element, elementControllers)

Source from the content-addressed store, hash-verified

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

Callers 1

nodeLinkFnFunction · 0.70

Calls 4

isStringFunction · 0.70
isArrayFunction · 0.70
isObjectFunction · 0.70
forEachFunction · 0.70

Tested by

no test coverage detected