diff options
| author | Alexander Shtuchkin | 2013-02-24 12:11:25 +0400 |
|---|---|---|
| committer | Igor Minar | 2013-02-25 10:58:10 -0800 |
| commit | 7d18d0ae262915e449bde97ad9dda3154d6d2d06 (patch) | |
| tree | be84bc74016d78f7c3c62d54aee7c629dfebc862 /src/ng/route.js | |
| parent | e27bb6eb132a68665c8fca3f5a216b19b1129ba6 (diff) | |
| download | angular.js-7d18d0ae262915e449bde97ad9dda3154d6d2d06.tar.bz2 | |
refactor($route): use $q#all hash signature 2 simplify 'resolve' impl
Diffstat (limited to 'src/ng/route.js')
| -rw-r--r-- | src/ng/route.js | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/src/ng/route.js b/src/ng/route.js index afdac3fb..0f8fe3e9 100644 --- a/src/ng/route.js +++ b/src/ng/route.js @@ -414,14 +414,13 @@ function $RouteProvider(){ $q.when(next). then(function() { if (next) { - var keys = [], - values = [], + var locals = extend({}, next.resolve), template; - forEach(next.resolve || {}, function(value, key) { - keys.push(key); - values.push(isString(value) ? $injector.get(value) : $injector.invoke(value)); + forEach(locals, function(value, key) { + locals[key] = isString(value) ? $injector.get(value) : $injector.invoke(value); }); + if (isDefined(template = next.template)) { if (isFunction(template)) { template = template(next.params); @@ -437,16 +436,9 @@ function $RouteProvider(){ } } if (isDefined(template)) { - keys.push('$template'); - values.push(template); + locals['$template'] = template; } - return $q.all(values).then(function(values) { - var locals = {}; - forEach(values, function(value, index) { - locals[keys[index]] = value; - }); - return locals; - }); + return $q.all(locals); } }). // after route change |
