diff options
Diffstat (limited to 'src/ng/compile.js')
| -rw-r--r-- | src/ng/compile.js | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/ng/compile.js b/src/ng/compile.js index 5b12883d..6aebe537 100644 --- a/src/ng/compile.js +++ b/src/ng/compile.js @@ -961,16 +961,25 @@ function $CompileProvider($provide) { $element: $element, $attrs: attrs, $transclude: boundTranscludeFn - }; + }, controllerInstance; controller = directive.controller; if (controller == '@') { controller = attrs[directive.name]; } + controllerInstance = $controller(controller, locals); $element.data( '$' + directive.name + 'Controller', - $controller(controller, locals)); + controllerInstance); + if (directive.controllerAs) { + if (typeof locals.$scope !== 'object') { + throw new Error('Can not export controller as "' + identifier + '". ' + + 'No scope object provided!'); + } + + locals.$scope[directive.controllerAs] = controllerInstance; + } }); } |
