MCPcopy
hub / github.com/angular-ui/ui-router / setupControllers

Function setupControllers

test/angular/1.7/angular.js:10695–10721  ·  view source on GitHub ↗
($element, attrs, transcludeFn, controllerDirectives, isolateScope, scope, newIsolateScopeDirective)

Source from the content-addressed store, hash-verified

10693 }
10694
10695 function setupControllers($element, attrs, transcludeFn, controllerDirectives, isolateScope, scope, newIsolateScopeDirective) {
10696 var elementControllers = createMap();
10697 for (var controllerKey in controllerDirectives) {
10698 var directive = controllerDirectives[controllerKey];
10699 var locals = {
10700 $scope: directive === newIsolateScopeDirective || directive.$$isolateScope ? isolateScope : scope,
10701 $element: $element,
10702 $attrs: attrs,
10703 $transclude: transcludeFn
10704 };
10705
10706 var controller = directive.controller;
10707 if (controller === '@') {
10708 controller = attrs[directive.name];
10709 }
10710
10711 var controllerInstance = $controller(controller, locals, true, directive.controllerAs);
10712
10713 // For directives with element transclusion the element is a comment.
10714 // In this case .data will not attach any data.
10715 // Instead, we save the controllers for the element in a local hash and attach to .data
10716 // later, once we have the actual element.
10717 elementControllers[directive.name] = controllerInstance;
10718 $element.data('$' + directive.name + 'Controller', controllerInstance.instance);
10719 }
10720 return elementControllers;
10721 }
10722
10723 // Depending upon the context in which a directive finds itself it might need to have a new isolated
10724 // or child scope created. For instance:

Callers 1

nodeLinkFnFunction · 0.70

Calls 1

createMapFunction · 0.70

Tested by

no test coverage detected