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 3b27dd3 commit fdbd92ff9933d0aa9809fa2f83cee56bfa738d86
Showing with 5 additions and 5 deletions.
  1. +2 −2 src/ng/compile.js
  2. +3 −3 test/ng/compileSpec.js
@@ -2660,8 +2660,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) {
@@ -3977,7 +3977,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;
@@ -3994,7 +3994,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
@@ -4051,7 +4051,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 fdbd92f

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