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

Function getControllers

lib/test/angular/1.8.0/angular.js:10709–10758  ·  view source on GitHub ↗
(directiveName, require, $element, elementControllers)

Source from the content-addressed store, hash-verified

10707 }
10708
10709 function getControllers(directiveName, require, $element, elementControllers) {
10710 var value;
10711
10712 if (isString(require)) {
10713 var match = require.match(REQUIRE_PREFIX_REGEXP);
10714 var name = require.substring(match[0].length);
10715 var inheritType = match[1] || match[3];
10716 var optional = match[2] === '?';
10717
10718 //If only parents then start at the parent element
10719 if (inheritType === '^^') {
10720 $element = $element.parent();
10721 //Otherwise attempt getting the controller from elementControllers in case
10722 //the element is transcluded (and has no data) and to avoid .data if possible
10723 } else {
10724 value = elementControllers && elementControllers[name];
10725 value = value && value.instance;
10726 }
10727
10728 if (!value) {
10729 var dataName = '$' + name + 'Controller';
10730
10731 if (inheritType === '^^' && $element[0] && $element[0].nodeType === NODE_TYPE_DOCUMENT) {
10732 // inheritedData() uses the documentElement when it finds the document, so we would
10733 // require from the element itself.
10734 value = null;
10735 } else {
10736 value = inheritType ? $element.inheritedData(dataName) : $element.data(dataName);
10737 }
10738 }
10739
10740 if (!value && !optional) {
10741 throw $compileMinErr('ctreq',
10742 'Controller \'{0}\', required by directive \'{1}\', can\'t be found!',
10743 name, directiveName);
10744 }
10745 } else if (isArray(require)) {
10746 value = [];
10747 for (var i = 0, ii = require.length; i < ii; i++) {
10748 value[i] = getControllers(directiveName, require[i], $element, elementControllers);
10749 }
10750 } else if (isObject(require)) {
10751 value = {};
10752 forEach(require, function(controller, property) {
10753 value[property] = getControllers(directiveName, controller, $element, elementControllers);
10754 });
10755 }
10756
10757 return value || null;
10758 }
10759
10760 function setupControllers($element, attrs, transcludeFn, controllerDirectives, isolateScope, scope, newIsolateScopeDirective) {
10761 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