mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-19 08:00:23 +00:00
refactor($route): use $q#all hash signature 2 simplify 'resolve' impl
This commit is contained in:
parent
e27bb6eb13
commit
7d18d0ae26
1 changed files with 6 additions and 14 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue