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

Commit c39936e

Browse files
refactor($route): move resolving locals into its own function
1 parent 4adc9a9 commit c39936e

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/ngRoute/route.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -601,15 +601,8 @@ function $RouteProvider() {
601601
$q.when(nextRoute).
602602
then(function() {
603603
if (nextRoute) {
604-
var locals = angular.extend({}, nextRoute.resolve),
605-
template, templateUrl;
606-
607-
angular.forEach(locals, function(value, key) {
608-
locals[key] = angular.isString(value) ?
609-
$injector.get(value) : $injector.invoke(value, null, null, key);
610-
});
611-
612-
template = getTemplateFor(nextRoute);
604+
var locals = resolveLocalsFor(nextRoute);
605+
var template = getTemplateFor(nextRoute);
613606
if (angular.isDefined(template)) {
614607
locals['$template'] = template;
615608
}
@@ -633,6 +626,16 @@ function $RouteProvider() {
633626
}
634627
}
635628

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;
637+
}
638+
636639

637640
function getTemplateFor(route) {
638641
var template, templateUrl;

0 commit comments

Comments
 (0)