diff options
| author | Jussi Kosunen | 2013-08-15 15:14:54 +0300 |
|---|---|---|
| committer | Vojta Jina | 2013-08-15 15:15:27 -0700 |
| commit | 3a65822023119b71deab5e298c7ef2de204caa13 (patch) | |
| tree | a10f4c3b80f786401b62cbd92e7941420c85f687 /src | |
| parent | 37123cd2858b4e318ed8109af745312df4848577 (diff) | |
| download | angular.js-3a65822023119b71deab5e298c7ef2de204caa13.tar.bz2 | |
fix($parse): handle promises returned from parsed function calls
When a parsed function call returns a promise, the evaluated value
is the resolved value of the promise rather than the promise object.
Closes #3503
Diffstat (limited to 'src')
| -rw-r--r-- | src/ng/parse.js | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/ng/parse.js b/src/ng/parse.js index 9eeb1439..5597acd8 100644 --- a/src/ng/parse.js +++ b/src/ng/parse.js @@ -689,9 +689,21 @@ function parser(text, json, $filter, csp){ } var fnPtr = fn(scope, locals, context) || noop; // IE stupidity! - return fnPtr.apply + var v = fnPtr.apply ? fnPtr.apply(context, args) : fnPtr(args[0], args[1], args[2], args[3], args[4]); + + // Check for promise + if (v && v.then) { + var p = v; + if (!('$$v' in v)) { + p.$$v = undefined; + p.then(function(val) { p.$$v = val; }); + } + v = v.$$v; + } + + return v; }; } |
