($element, attrs, transcludeFn, controllerDirectives, isolateScope, scope, newIsolateScopeDirective)
| 10175 | } |
| 10176 | |
| 10177 | function setupControllers($element, attrs, transcludeFn, controllerDirectives, isolateScope, scope, newIsolateScopeDirective) { |
| 10178 | var elementControllers = createMap(); |
| 10179 | for (var controllerKey in controllerDirectives) { |
| 10180 | var directive = controllerDirectives[controllerKey]; |
| 10181 | var locals = { |
| 10182 | $scope: directive === newIsolateScopeDirective || directive.$$isolateScope ? isolateScope : scope, |
| 10183 | $element: $element, |
| 10184 | $attrs: attrs, |
| 10185 | $transclude: transcludeFn |
| 10186 | }; |
| 10187 | |
| 10188 | var controller = directive.controller; |
| 10189 | if (controller === '@') { |
| 10190 | controller = attrs[directive.name]; |
| 10191 | } |
| 10192 | |
| 10193 | var controllerInstance = $controller(controller, locals, true, directive.controllerAs); |
| 10194 | |
| 10195 | // For directives with element transclusion the element is a comment. |
| 10196 | // In this case .data will not attach any data. |
| 10197 | // Instead, we save the controllers for the element in a local hash and attach to .data |
| 10198 | // later, once we have the actual element. |
| 10199 | elementControllers[directive.name] = controllerInstance; |
| 10200 | $element.data('$' + directive.name + 'Controller', controllerInstance.instance); |
| 10201 | } |
| 10202 | return elementControllers; |
| 10203 | } |
| 10204 | |
| 10205 | // Depending upon the context in which a directive finds itself it might need to have a new isolated |
| 10206 | // or child scope created. For instance: |
no test coverage detected