Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 4c95ad8

Browse files
refactor($route): consolidate route locals processing into a single handler
1 parent c39936e commit 4c95ad8

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
@@ -599,16 +599,7 @@ function $RouteProvider() {
599599
}
600600

601601
$q.when(nextRoute).
602-
then(function() {
603-
if (nextRoute) {
604-
var locals = resolveLocalsFor(nextRoute);
605-
var template = getTemplateFor(nextRoute);
606-
if (angular.isDefined(template)) {
607-
locals['$template'] = template;
608-
}
609-
return $q.all(locals);
610-
}
611-
}).
602+
then(resolveLocals).
612603
then(function(locals) {
613604
// after route change
614605
if (nextRoute === $route.current) {
@@ -626,14 +617,20 @@ function $RouteProvider() {
626617
}
627618
}
628619

629-
function resolveLocalsFor(route) {
630-
var locals = angular.extend({}, route.resolve);
631-
angular.forEach(locals, function(value, key) {
632-
locals[key] = angular.isString(value) ?
633-
$injector.get(value) :
634-
$injector.invoke(value, null, null, key);
635-
});
636-
return locals;
620+
function resolveLocals(route) {
621+
if (route) {
622+
var locals = angular.extend({}, route.resolve);
623+
angular.forEach(locals, function(value, key) {
624+
locals[key] = angular.isString(value) ?
625+
$injector.get(value) :
626+
$injector.invoke(value, null, null, key);
627+
});
628+
var template = getTemplateFor(route);
629+
if (angular.isDefined(template)) {
630+
locals['$template'] = template;
631+
}
632+
return $q.all(locals);
633+
}
637634
}
638635

639636

0 commit comments

Comments
 (0)