Skip to content

Commit 7db30b1

Browse files
refactor($route): consolidate route locals processing into a single handler
1 parent 3aecef9 commit 7db30b1

File tree

1 file changed

+15
-18
lines changed

1 file changed

+15
-18
lines changed

src/ngRoute/route.js

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -606,16 +606,7 @@ function $RouteProvider() {
606606
}
607607

608608
$q.when(nextRoute).
609-
then(function() {
610-
if (nextRoute) {
611-
var locals = resolveLocalsFor(nextRoute);
612-
var template = getTemplateFor(nextRoute);
613-
if (angular.isDefined(template)) {
614-
locals['$template'] = template;
615-
}
616-
return $q.all(locals);
617-
}
618-
}).
609+
then(resolveLocals).
619610
then(function(locals) {
620611
// after route change
621612
if (nextRoute === $route.current) {
@@ -633,14 +624,20 @@ function $RouteProvider() {
633624
}
634625
}
635626

636-
function resolveLocalsFor(route) {
637-
var locals = angular.extend({}, route.resolve);
638-
angular.forEach(locals, function(value, key) {
639-
locals[key] = angular.isString(value) ?
640-
$injector.get(value) :
641-
$injector.invoke(value, null, null, key);
642-
});
643-
return locals;
627+
function resolveLocals(route) {
628+
if (route) {
629+
var locals = angular.extend({}, route.resolve);
630+
angular.forEach(locals, function(value, key) {
631+
locals[key] = angular.isString(value) ?
632+
$injector.get(value) :
633+
$injector.invoke(value, null, null, key);
634+
});
635+
var template = getTemplateFor(route);
636+
if (angular.isDefined(template)) {
637+
locals['$template'] = template;
638+
}
639+
return $q.all(locals);
640+
}
644641
}
645642

646643

0 commit comments

Comments
 (0)