Skip to content

Commit 7d18d0a

Browse files
ashtuchkinIgorMinar
authored andcommitted
refactor($route): use $q#all hash signature 2 simplify 'resolve' impl
1 parent e27bb6e commit 7d18d0a

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

src/ng/route.js

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -414,14 +414,13 @@ function $RouteProvider(){
414414
$q.when(next).
415415
then(function() {
416416
if (next) {
417-
var keys = [],
418-
values = [],
417+
var locals = extend({}, next.resolve),
419418
template;
420419

421-
forEach(next.resolve || {}, function(value, key) {
422-
keys.push(key);
423-
values.push(isString(value) ? $injector.get(value) : $injector.invoke(value));
420+
forEach(locals, function(value, key) {
421+
locals[key] = isString(value) ? $injector.get(value) : $injector.invoke(value);
424422
});
423+
425424
if (isDefined(template = next.template)) {
426425
if (isFunction(template)) {
427426
template = template(next.params);
@@ -437,16 +436,9 @@ function $RouteProvider(){
437436
}
438437
}
439438
if (isDefined(template)) {
440-
keys.push('$template');
441-
values.push(template);
439+
locals['$template'] = template;
442440
}
443-
return $q.all(values).then(function(values) {
444-
var locals = {};
445-
forEach(values, function(value, index) {
446-
locals[keys[index]] = value;
447-
});
448-
return locals;
449-
});
441+
return $q.all(locals);
450442
}
451443
}).
452444
// after route change

0 commit comments

Comments
 (0)