MCPcopy Create free account
hub / github.com/cafebazaar/blacksmith / getControllers

Function getControllers

web/static/bower_components/angular/angular.js:8121–8158  ·  view source on GitHub ↗
(directiveName, require, $element, elementControllers)

Source from the content-addressed store, hash-verified

8119
8120
8121 function getControllers(directiveName, require, $element, elementControllers) {
8122 var value;
8123
8124 if (isString(require)) {
8125 var match = require.match(REQUIRE_PREFIX_REGEXP);
8126 var name = require.substring(match[0].length);
8127 var inheritType = match[1] || match[3];
8128 var optional = match[2] === '?';
8129
8130 //If only parents then start at the parent element
8131 if (inheritType === '^^') {
8132 $element = $element.parent();
8133 //Otherwise attempt getting the controller from elementControllers in case
8134 //the element is transcluded (and has no data) and to avoid .data if possible
8135 } else {
8136 value = elementControllers && elementControllers[name];
8137 value = value && value.instance;
8138 }
8139
8140 if (!value) {
8141 var dataName = '$' + name + 'Controller';
8142 value = inheritType ? $element.inheritedData(dataName) : $element.data(dataName);
8143 }
8144
8145 if (!value && !optional) {
8146 throw $compileMinErr('ctreq',
8147 "Controller '{0}', required by directive '{1}', can't be found!",
8148 name, directiveName);
8149 }
8150 } else if (isArray(require)) {
8151 value = [];
8152 for (var i = 0, ii = require.length; i < ii; i++) {
8153 value[i] = getControllers(directiveName, require[i], $element, elementControllers);
8154 }
8155 }
8156
8157 return value || null;
8158 }
8159
8160 function setupControllers($element, attrs, transcludeFn, controllerDirectives, isolateScope, scope) {
8161 var elementControllers = createMap();

Callers 1

nodeLinkFnFunction · 0.85

Calls 1

isStringFunction · 0.85

Tested by

no test coverage detected