From dc75d59e05da3b2a80b1a6708449c1da83e4cc71 Mon Sep 17 00:00:00 2001 From: Wesley Cho Date: Fri, 22 Jan 2016 12:44:10 -0800 Subject: [PATCH] docs(compile): improve nonassign error message - Improve error message to mention attribute the expression errored on Fixes #13827 --- src/ng/compile.js | 4 ++-- test/ng/compileSpec.js | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ng/compile.js b/src/ng/compile.js index 2d2bede440da..0b83a7bae39f 100644 --- a/src/ng/compile.js +++ b/src/ng/compile.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) { diff --git a/test/ng/compileSpec.js b/test/ng/compileSpec.js index 070af19abeb1..47f8e9ec9046 100755 --- a/test/ng/compileSpec.js +++ b/test/ng/compileSpec.js @@ -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!"); }));