Improve this Doc

Error: $compile:nonassign
Non-Assignable Expression

Expression '{0}' in attribute '{1}' used with directive '{2}' is non-assignable!

Description

This error occurs when a directive defines an isolate scope property (using the = mode in the scope option of a 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: {
      localValue: '=bind'
    }
    ...
  }
});

Following are invalid uses of this directive:

<!-- ERROR because `1+2=localValue` is an invalid statement -->
<my-directive bind="1+2">

<!-- ERROR because `myFn()=localValue` is an invalid statement -->
<my-directive bind="myFn()">

<!-- ERROR because attribute bind wasn't provided -->
<my-directive>

To resolve this error, do one of the following options:

<my-directive bind="some.property">
<my-directive bind="some[3]['property']">
myModule.directive('myDirective', function factory() {
  return {
    ...
    scope: {
      localValue: '=?bind' // <-- the '?' makes it optional
    }
    ...
  }
});