Skip to content
Permalink
Browse files

docs(compile): improve nonassign error message

- Improve error message to mention attribute the expression errored on

Fixes #13827

Closes #13828
  • Loading branch information
wesleycho authored and Narretz committed Jan 22, 2016
1 parent 20b8ece commit 4ff9c027b097feaf47b7b474d26d5d9a59bc8fef
Showing with 5 additions and 5 deletions.
  1. +2 −2 src/ng/compile.js
  2. +3 −3 test/ng/compileSpec.js
@@ -3120,8 +3120,8 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
// reset the change, or we will throw this exception on every $digest
lastValue = destination[scopeName] = parentGet(scope);
throw $compileMinErr('nonassign',
"Expression '{0}' used with directive '{1}' is non-assignable!",
attrs[attrName], directive.name);
"Expression '{0}' in attribute '{1}' used with directive '{2}' is non-assignable!",
attrs[attrName], attrName, directive.name);
};
lastValue = destination[scopeName] = parentGet(scope);
var parentValueWatch = function parentValueWatch(parentValue) {
@@ -3996,7 +3996,7 @@ describe('$compile', function() {

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

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

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

}));

0 comments on commit 4ff9c02

Please sign in to comment.
You can’t perform that action at this time.