Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9317e43

Browse files
committed
chore($compile): use minErr on "as instance" syntax
1 parent fda5eb7 commit 9317e43

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
@ngdoc error
2+
@name $compile:enscp
3+
@fullName Can not export controller as no scope object is provided
4+
@description
5+
If the directive doesn't have a local scope or is not a valid object, you can not export
6+
the controller. Please specify the scope element the defining the directive, even if its
7+
empty.
8+
9+
<pre>
10+
myModule.directive('directiveName', function factory() {
11+
return {
12+
...
13+
controllerAs: 'DirCtrl'; // ERROR: no local scope specified
14+
...
15+
}
16+
});
17+
</pre>
18+
19+
<pre>
20+
myModule.directive('directiveName', function factory() {
21+
return {
22+
...
23+
scope: {},
24+
controllerAs: 'DirCtrl'; // OK: local scope is a valid object
25+
...
26+
}
27+
});
28+
</pre>

src/ng/compile.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,8 +1036,8 @@ function $CompileProvider($provide) {
10361036
controllerInstance);
10371037
if (directive.controllerAs) {
10381038
if (typeof locals.$scope !== 'object') {
1039-
throw new Error('Can not export controller as "' + identifier + '". ' +
1040-
'No scope object provided!');
1039+
throw $compileMinErr('enscp', "Can not export controller as '{0}' as no scope object is provided!'",
1040+
identifier);
10411041
}
10421042

10431043
locals.$scope[directive.controllerAs] = controllerInstance;

0 commit comments

Comments
 (0)