angular/angular.js — pull request #2854 by zoomzoom83 (2013-06-03 04:38:39+00:00)
Title: fix($parse) - Allow setterFn to bind correctly to promise results

When binding the result of a promise directly to an ng:model directive,
getterFn successfully extracts the data from the promise by traversing
the '$$v' attribute.

However the setterFn was not successfully traversing to the $$v
attribute, and instead writing model updates directly on the promise
itself.

The subsequent apply/digest phase of Angular was then pulling the
original value from the promise and applying it back into the viewState,
thus simulating a read-only field.

In summary, setterFn was writing to the root of the promise, while
getterFn was reading from the '$$v' component.

Fixed by modifying setterFn to unwrap promises if found and read $$v.

If promises have not been resolved yet, bindings will function as they
previously did (act as a read-only field). This appears to be more of a
side effect than intentional design in the existing codebase, however
I kept this behaviour in this patch to minimize the chance of breaking
existing projects.

Closes #1827

This issue affects the 1.0.x branch as well and would be worth backporting.

Also see: http://stackoverflow.com/questions/16883239/angularjs-ngmodel-
field-is-readonly-when-bound-to-q-promise/16883387