Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

chore($compile): use minErr on "as instance" syntax #3517

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions docs/content/error/compile/enscp.ngdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
@ngdoc error
@name $compile:enscp
@fullName Can not export controller as no scope object is provided
@description
If the directive doesn't have a local scope or is not a valid object, you can not export
the controller. Please specify the scope element the defining the directive, even if its
empty.

<pre>
myModule.directive('directiveName', function factory() {
return {
...
controllerAs: 'DirCtrl'; // ERROR: no local scope specified
...
}
});
</pre>

<pre>
myModule.directive('directiveName', function factory() {
return {
...
scope: {},
controllerAs: 'DirCtrl'; // OK: local scope is a valid object
...
}
});
</pre>
4 changes: 2 additions & 2 deletions src/ng/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -1036,8 +1036,8 @@ function $CompileProvider($provide) {
controllerInstance);
if (directive.controllerAs) {
if (typeof locals.$scope !== 'object') {
throw new Error('Can not export controller as "' + identifier + '". ' +
'No scope object provided!');
throw $compileMinErr('enscp', "Can not export controller as '{0}' as no scope object is provided!'",
identifier);
}

locals.$scope[directive.controllerAs] = controllerInstance;
Expand Down