Permalink
Comparing changes
Open a pull request
- 3 commits
- 1 file changed
- 0 commit comments
- 1 contributor
Commits on May 24, 2016
…andler
Unified
Split
Showing
with
36 additions
and 29 deletions.
- +36 −29 src/ngRoute/route.js
| @@ -599,35 +599,7 @@ function $RouteProvider() { | ||
| } | ||
|
|
||
| $q.when(nextRoute). | ||
| then(function() { | ||
| if (nextRoute) { | ||
| var locals = angular.extend({}, nextRoute.resolve), | ||
| template, templateUrl; | ||
|
|
||
| angular.forEach(locals, function(value, key) { | ||
| locals[key] = angular.isString(value) ? | ||
| $injector.get(value) : $injector.invoke(value, null, null, key); | ||
| }); | ||
|
|
||
| if (angular.isDefined(template = nextRoute.template)) { | ||
| if (angular.isFunction(template)) { | ||
| template = template(nextRoute.params); | ||
| } | ||
| } else if (angular.isDefined(templateUrl = nextRoute.templateUrl)) { | ||
| if (angular.isFunction(templateUrl)) { | ||
| templateUrl = templateUrl(nextRoute.params); | ||
| } | ||
| if (angular.isDefined(templateUrl)) { | ||
| nextRoute.loadedTemplateUrl = $sce.valueOf(templateUrl); | ||
| template = $templateRequest(templateUrl); | ||
| } | ||
| } | ||
| if (angular.isDefined(template)) { | ||
| locals['$template'] = template; | ||
| } | ||
| return $q.all(locals); | ||
| } | ||
| }). | ||
| then(resolveLocals). | ||
| then(function(locals) { | ||
| // after route change | ||
| if (nextRoute == $route.current) { | ||
| @@ -645,6 +617,41 @@ function $RouteProvider() { | ||
| } | ||
| } | ||
|
|
||
| function resolveLocals(route) { | ||
| if (route) { | ||
| var locals = angular.extend({}, route.resolve); | ||
| angular.forEach(locals, function(value, key) { | ||
| locals[key] = angular.isString(value) ? | ||
| $injector.get(value) : | ||
| $injector.invoke(value, null, null, key); | ||
| }); | ||
| var template = getTemplateFor(route); | ||
| if (angular.isDefined(template)) { | ||
| locals['$template'] = template; | ||
| } | ||
| return $q.all(locals); | ||
| } | ||
| } | ||
|
|
||
|
|
||
| function getTemplateFor(route) { | ||
| var template, templateUrl; | ||
| if (angular.isDefined(template = route.template)) { | ||
| if (angular.isFunction(template)) { | ||
| template = template(route.params); | ||
| } | ||
| } else if (angular.isDefined(templateUrl = route.templateUrl)) { | ||
| if (angular.isFunction(templateUrl)) { | ||
| templateUrl = templateUrl(route.params); | ||
| } | ||
| if (angular.isDefined(templateUrl)) { | ||
| route.loadedTemplateUrl = $sce.valueOf(templateUrl); | ||
| template = $templateRequest(templateUrl); | ||
| } | ||
| } | ||
| return template; | ||
| } | ||
|
|
||
|
|
||
| /** | ||
| * @returns {Object} the current active route, by matching it against the URL | ||