27 lines
1.8 KiB
HTML
Executable file
27 lines
1.8 KiB
HTML
Executable file
<a href="http://github.com/angular/angular.js/edit/master/docs/content/error/compile/nonassign.ngdoc" class="improve-docs btn btn-primary"><i class="icon-edit"> </i> Improve this doc</a><h1><code ng:non-bindable="">Non-Assignable Expression</code>
|
|
<div><span class="hint">error in component <code ng:non-bindable="">$compile</code>
|
|
</span>
|
|
</div>
|
|
</h1>
|
|
<div><pre class="minerr-errmsg" error-display="Expression '{0}' used with directive '{1}' is non-assignable!">Expression '{0}' used with directive '{1}' is non-assignable!</pre>
|
|
<h2 id="Description">Description</h2>
|
|
<div class="description"><div class="-compile-page -compile-nonassign-page"><p>This error occurs when a directive defines an isolate scope property that support two-way data-binding (using the <code>=</code> mode in the <a href="guide/directive#directivedefinitionobject">directive definition</a>) but the directive is used with an expression that is not-assignable.</p>
|
|
<p>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.</p>
|
|
<p>For example, given a directive:</p>
|
|
<pre><code>myModule.directive('myDirective', function factory() {
|
|
return {
|
|
...
|
|
scope: {
|
|
'bind': '=localValue'
|
|
}
|
|
...
|
|
}
|
|
});</code></pre>
|
|
<p>Following are invalid uses of this directive:</p>
|
|
<pre><code><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 --></code></pre>
|
|
<p>To resolve this error, always use path expressions with scope properties that are two-way data-bound:</p>
|
|
<pre><code><my-directive bind="some.property">
|
|
<my-directive bind="some[3]['property']"></code></pre>
|
|
</div></div>
|
|
</div>
|