docs($compile): improve nonassign error message
- Improve error message to mention attribute the expression errored on Fixes #13827 Closes #13828
This commit is contained in:
committed by
Martin Staffa
parent
3b27dd37a2
commit
fdbd92ff99
+2
-2
@@ -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!");
|
||||
|
||||
}));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user