aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--docs/content/error/compile/noass.ngdoc4
-rw-r--r--docs/content/error/compile/nonassign.ngdoc36
-rw-r--r--src/ng/compile.js2
-rwxr-xr-xtest/ng/compileSpec.js4
4 files changed, 39 insertions, 7 deletions
diff --git a/docs/content/error/compile/noass.ngdoc b/docs/content/error/compile/noass.ngdoc
deleted file mode 100644
index bb247499..00000000
--- a/docs/content/error/compile/noass.ngdoc
+++ /dev/null
@@ -1,4 +0,0 @@
-@ngdoc error
-@name $compile:noass
-@fullName Non-Assignable Expression
-@description
diff --git a/docs/content/error/compile/nonassign.ngdoc b/docs/content/error/compile/nonassign.ngdoc
new file mode 100644
index 00000000..f3c4dd2c
--- /dev/null
+++ b/docs/content/error/compile/nonassign.ngdoc
@@ -0,0 +1,36 @@
+@ngdoc error
+@name $compile:nonassign
+@fullName Non-Assignable Expression
+@description
+
+This error occurs when a directive defines an isolate scope property that support two-way data-binding (using the `=` mode in the {@link guide/directive#directivedefinitionobject directive definition}) but the directive is used with an expression that is not-assignable.
+
+In order for the two-way data-binding to work, it must be possible to write new values back into the path defined with the expression.
+
+For example, given a directive:
+
+```
+myModule.directive('myDirective', function factory() {
+ return {
+ ...
+ scope: {
+ 'bind': '=localValue'
+ }
+ ...
+ }
+});
+```
+
+Following are invalid uses of this directive:
+```
+<my-directive bind="1+2"> <!-- ERROR because `1+2=localValue` is an invalid statement -->
+<my-directive bind="myFn()"> <!-- ERROR because `myFn()=localValue` is an invalid statement -->
+```
+
+
+To resolve this error, always use path expressions with scope properties that are two-way data-bound:
+```
+<my-directive bind="some.property">
+<my-directive bind="some[3]['property']">
+```
+
diff --git a/src/ng/compile.js b/src/ng/compile.js
index c2eeae27..f2c7b381 100644
--- a/src/ng/compile.js
+++ b/src/ng/compile.js
@@ -978,7 +978,7 @@ function $CompileProvider($provide) {
parentSet = parentGet.assign || function() {
// reset the change, or we will throw this exception on every $digest
lastValue = scope[scopeName] = parentGet(parentScope);
- throw $compileMinErr('noass', "Expression '{0}' used with directive '{1}' is non-assignable!",
+ throw $compileMinErr('nonassign', "Expression '{0}' used with directive '{1}' is non-assignable!",
attrs[attrName], newIsolateScopeDirective.name);
};
lastValue = scope[scopeName] = parentGet(parentScope);
diff --git a/test/ng/compileSpec.js b/test/ng/compileSpec.js
index f7f2c51b..7525806c 100755
--- a/test/ng/compileSpec.js
+++ b/test/ng/compileSpec.js
@@ -2110,7 +2110,7 @@ describe('$compile', function() {
componentScope.ref = 'ignore me';
expect($rootScope.$apply).
- toThrow("[$compile:noass] Expression ''hello ' + name' used with directive 'myComponent' is non-assignable!");
+ toThrow("[$compile:nonassign] Expression ''hello ' + name' 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;
@@ -3240,7 +3240,7 @@ describe('$compile', function() {
};
});
});
- inject(function($compile, $rootScope) {
+ inject(function($compile) {
expect(function() {
element = $compile(
'<div>' +