mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-03 09:05:37 +08:00
docs(compile/notassign): description for compile/notassign error
Closes #3459
This commit is contained in:
@@ -1,4 +0,0 @@
|
||||
@ngdoc error
|
||||
@name $compile:noass
|
||||
@fullName Non-Assignable Expression
|
||||
@description
|
||||
36
docs/content/error/compile/nonassign.ngdoc
Normal file
36
docs/content/error/compile/nonassign.ngdoc
Normal file
@@ -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']">
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user