diff options
| author | James Davies | 2013-06-03 13:04:12 +1000 |
|---|---|---|
| committer | Chirayu Krishnappa | 2013-07-31 16:22:24 -0700 |
| commit | 61906d3517428b6d52d3284b8d26d1a46e01dad7 (patch) | |
| tree | d8196c069eaa60414664b2b1d2a76f15a13d7262 /src | |
| parent | 0bbd20f255b2954b5c41617fe718cf6eca36a972 (diff) | |
| download | angular.js-61906d3517428b6d52d3284b8d26d1a46e01dad7.tar.bz2 | |
fix($parse): unwrap promise when setting a field
This fixes an inconsistency where you can't call the setter function
when the expression resolves to a top level field name on a promise.
Setting a field on an unresolved promise will throw an exception. (This
shouldn't really happen in your template/js code and points to a
programming error.)
Closes #1827
Diffstat (limited to 'src')
| -rw-r--r-- | src/ng/parse.js | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/ng/parse.js b/src/ng/parse.js index 9660c76f..7c244bd8 100644 --- a/src/ng/parse.js +++ b/src/ng/parse.js @@ -766,6 +766,17 @@ function setter(obj, path, setValue, fullExp) { obj[key] = propertyObj; } obj = propertyObj; + if (obj.then) { + if (!("$$v" in obj)) { + (function(promise) { + promise.then(function(val) { promise.$$v = val; }); } + )(obj); + } + if (obj.$$v === undefined) { + obj.$$v = {}; + } + obj = obj.$$v; + } } key = ensureSafeMemberName(element.shift(), fullExp); obj[key] = setValue; |
