mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-14 17:53:11 +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).
|
$q.when(next).
|
||||||
then(function() {
|
then(function() {
|
||||||
if (next) {
|
if (next) {
|
||||||
var keys = [],
|
var locals = extend({}, next.resolve),
|
||||||
values = [],
|
|
||||||
template;
|
template;
|
||||||
|
|
||||||
forEach(next.resolve || {}, function(value, key) {
|
forEach(locals, function(value, key) {
|
||||||
keys.push(key);
|
locals[key] = isString(value) ? $injector.get(value) : $injector.invoke(value);
|
||||||
values.push(isString(value) ? $injector.get(value) : $injector.invoke(value));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (isDefined(template = next.template)) {
|
if (isDefined(template = next.template)) {
|
||||||
if (isFunction(template)) {
|
if (isFunction(template)) {
|
||||||
template = template(next.params);
|
template = template(next.params);
|
||||||
|
|
@ -437,16 +436,9 @@ function $RouteProvider(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isDefined(template)) {
|
if (isDefined(template)) {
|
||||||
keys.push('$template');
|
locals['$template'] = template;
|
||||||
values.push(template);
|
|
||||||
}
|
}
|
||||||
return $q.all(values).then(function(values) {
|
return $q.all(locals);
|
||||||
var locals = {};
|
|
||||||
forEach(values, function(value, index) {
|
|
||||||
locals[keys[index]] = value;
|
|
||||||
});
|
|
||||||
return locals;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}).
|
}).
|
||||||
// after route change
|
// after route change
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue