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

Commit 4ff9c02

Browse files
wesleychoNarretz
authored andcommitted
docs(compile): improve nonassign error message
- Improve error message to mention attribute the expression errored on Fixes #13827 Closes #13828
1 parent 20b8ece commit 4ff9c02

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/ng/compile.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -3120,8 +3120,8 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
31203120
// reset the change, or we will throw this exception on every $digest
31213121
lastValue = destination[scopeName] = parentGet(scope);
31223122
throw $compileMinErr('nonassign',
3123-
"Expression '{0}' used with directive '{1}' is non-assignable!",
3124-
attrs[attrName], directive.name);
3123+
"Expression '{0}' in attribute '{1}' used with directive '{2}' is non-assignable!",
3124+
attrs[attrName], attrName, directive.name);
31253125
};
31263126
lastValue = destination[scopeName] = parentGet(scope);
31273127
var parentValueWatch = function parentValueWatch(parentValue) {

test/ng/compileSpec.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -3996,7 +3996,7 @@ describe('$compile', function() {
39963996

39973997
componentScope.ref = 'ignore me';
39983998
expect(function() { $rootScope.$apply(); }).
3999-
toThrowMinErr("$compile", "nonassign", "Expression ''hello ' + name' used with directive 'myComponent' is non-assignable!");
3999+
toThrowMinErr("$compile", "nonassign", "Expression ''hello ' + name' in attribute 'ref' used with directive 'myComponent' is non-assignable!");
40004000
expect(componentScope.ref).toBe('hello world');
40014001
// reset since the exception was rethrown which prevented phase clearing
40024002
$rootScope.$$phase = null;
@@ -4013,7 +4013,7 @@ describe('$compile', function() {
40134013

40144014
componentScope.ref = 'ignore me';
40154015
expect(function() { $rootScope.$apply(); }).
4016-
toThrowMinErr("$compile", "nonassign", "Expression 'undefined' used with directive 'myComponent' is non-assignable!");
4016+
toThrowMinErr("$compile", "nonassign", "Expression 'undefined' in attribute 'ref' used with directive 'myComponent' is non-assignable!");
40174017
expect(componentScope.ref).toBeUndefined();
40184018

40194019
$rootScope.$$phase = null; // reset since the exception was rethrown which prevented phase clearing
@@ -4070,7 +4070,7 @@ describe('$compile', function() {
40704070
componentScope.reference = {name: 'b'};
40714071
expect(function() {
40724072
$rootScope.$apply();
4073-
}).toThrowMinErr("$compile", "nonassign", "Expression '{name: name}' used with directive 'myComponent' is non-assignable!");
4073+
}).toThrowMinErr("$compile", "nonassign", "Expression '{name: name}' in attribute 'reference' used with directive 'myComponent' is non-assignable!");
40744074

40754075
}));
40764076

0 commit comments

Comments
 (0)