($element, attrs, transcludeFn, controllerDirectives, isolateScope, scope, newIsolateScopeDirective)
| 10098 | } |
| 10099 | |
| 10100 | function setupControllers($element, attrs, transcludeFn, controllerDirectives, isolateScope, scope, newIsolateScopeDirective) { |
| 10101 | var elementControllers = createMap(); |
| 10102 | for (var controllerKey in controllerDirectives) { |
| 10103 | var directive = controllerDirectives[controllerKey]; |
| 10104 | var locals = { |
| 10105 | $scope: directive === newIsolateScopeDirective || directive.$$isolateScope ? isolateScope : scope, |
| 10106 | $element: $element, |
| 10107 | $attrs: attrs, |
| 10108 | $transclude: transcludeFn |
| 10109 | }; |
| 10110 | |
| 10111 | var controller = directive.controller; |
| 10112 | if (controller === '@') { |
| 10113 | controller = attrs[directive.name]; |
| 10114 | } |
| 10115 | |
| 10116 | var controllerInstance = $controller(controller, locals, true, directive.controllerAs); |
| 10117 | |
| 10118 | // For directives with element transclusion the element is a comment. |
| 10119 | // In this case .data will not attach any data. |
| 10120 | // Instead, we save the controllers for the element in a local hash and attach to .data |
| 10121 | // later, once we have the actual element. |
| 10122 | elementControllers[directive.name] = controllerInstance; |
| 10123 | $element.data('$' + directive.name + 'Controller', controllerInstance.instance); |
| 10124 | } |
| 10125 | return elementControllers; |
| 10126 | } |
| 10127 | |
| 10128 | // Depending upon the context in which a directive finds itself it might need to have a new isolated |
| 10129 | // or child scope created. For instance: |
no test coverage detected