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

Function getControllers

lib/test/angular/1.5.0/angular.js:8792–8834  ·  view source on GitHub ↗
(directiveName, require, $element, elementControllers)

Source from the content-addressed store, hash-verified

8790
8791
8792 function getControllers(directiveName, require, $element, elementControllers) {
8793 var value;
8794
8795 if (isString(require)) {
8796 var match = require.match(REQUIRE_PREFIX_REGEXP);
8797 var name = require.substring(match[0].length);
8798 var inheritType = match[1] || match[3];
8799 var optional = match[2] === '?';
8800
8801 //If only parents then start at the parent element
8802 if (inheritType === '^^') {
8803 $element = $element.parent();
8804 //Otherwise attempt getting the controller from elementControllers in case
8805 //the element is transcluded (and has no data) and to avoid .data if possible
8806 } else {
8807 value = elementControllers && elementControllers[name];
8808 value = value && value.instance;
8809 }
8810
8811 if (!value) {
8812 var dataName = '$' + name + 'Controller';
8813 value = inheritType ? $element.inheritedData(dataName) : $element.data(dataName);
8814 }
8815
8816 if (!value && !optional) {
8817 throw $compileMinErr('ctreq',
8818 "Controller '{0}', required by directive '{1}', can't be found!",
8819 name, directiveName);
8820 }
8821 } else if (isArray(require)) {
8822 value = [];
8823 for (var i = 0, ii = require.length; i < ii; i++) {
8824 value[i] = getControllers(directiveName, require[i], $element, elementControllers);
8825 }
8826 } else if (isObject(require)) {
8827 value = {};
8828 forEach(require, function(controller, property) {
8829 value[property] = getControllers(directiveName, controller, $element, elementControllers);
8830 });
8831 }
8832
8833 return value || null;
8834 }
8835
8836 function setupControllers($element, attrs, transcludeFn, controllerDirectives, isolateScope, scope) {
8837 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