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

Function getControllers

lib/test/angular/1.6.7/angular.js:10056–10098  ·  view source on GitHub ↗
(directiveName, require, $element, elementControllers)

Source from the content-addressed store, hash-verified

10054 }
10055
10056 function getControllers(directiveName, require, $element, elementControllers) {
10057 var value;
10058
10059 if (isString(require)) {
10060 var match = require.match(REQUIRE_PREFIX_REGEXP);
10061 var name = require.substring(match[0].length);
10062 var inheritType = match[1] || match[3];
10063 var optional = match[2] === '?';
10064
10065 //If only parents then start at the parent element
10066 if (inheritType === '^^') {
10067 $element = $element.parent();
10068 //Otherwise attempt getting the controller from elementControllers in case
10069 //the element is transcluded (and has no data) and to avoid .data if possible
10070 } else {
10071 value = elementControllers && elementControllers[name];
10072 value = value && value.instance;
10073 }
10074
10075 if (!value) {
10076 var dataName = '$' + name + 'Controller';
10077 value = inheritType ? $element.inheritedData(dataName) : $element.data(dataName);
10078 }
10079
10080 if (!value && !optional) {
10081 throw $compileMinErr('ctreq',
10082 'Controller \'{0}\', required by directive \'{1}\', can\'t be found!',
10083 name, directiveName);
10084 }
10085 } else if (isArray(require)) {
10086 value = [];
10087 for (var i = 0, ii = require.length; i < ii; i++) {
10088 value[i] = getControllers(directiveName, require[i], $element, elementControllers);
10089 }
10090 } else if (isObject(require)) {
10091 value = {};
10092 forEach(require, function(controller, property) {
10093 value[property] = getControllers(directiveName, controller, $element, elementControllers);
10094 });
10095 }
10096
10097 return value || null;
10098 }
10099
10100 function setupControllers($element, attrs, transcludeFn, controllerDirectives, isolateScope, scope, newIsolateScopeDirective) {
10101 var elementControllers = createMap();

Callers 1

nodeLinkFnFunction · 0.70

Calls 4

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

Tested by

no test coverage detected