@@ -609,19 +609,7 @@ function $RouteProvider() {
609
609
$injector . get ( value ) : $injector . invoke ( value , null , null , key ) ;
610
610
} ) ;
611
611
612
- if ( angular . isDefined ( template = nextRoute . template ) ) {
613
- if ( angular . isFunction ( template ) ) {
614
- template = template ( nextRoute . params ) ;
615
- }
616
- } else if ( angular . isDefined ( templateUrl = nextRoute . templateUrl ) ) {
617
- if ( angular . isFunction ( templateUrl ) ) {
618
- templateUrl = templateUrl ( nextRoute . params ) ;
619
- }
620
- if ( angular . isDefined ( templateUrl ) ) {
621
- nextRoute . loadedTemplateUrl = $sce . valueOf ( templateUrl ) ;
622
- template = $templateRequest ( templateUrl ) ;
623
- }
624
- }
612
+ template = getTemplateFor ( nextRoute ) ;
625
613
if ( angular . isDefined ( template ) ) {
626
614
locals [ '$template' ] = template ;
627
615
}
@@ -646,6 +634,25 @@ function $RouteProvider() {
646
634
}
647
635
648
636
637
+ function getTemplateFor ( route ) {
638
+ var template , templateUrl ;
639
+ if ( angular . isDefined ( template = route . template ) ) {
640
+ if ( angular . isFunction ( template ) ) {
641
+ template = template ( route . params ) ;
642
+ }
643
+ } else if ( angular . isDefined ( templateUrl = route . templateUrl ) ) {
644
+ if ( angular . isFunction ( templateUrl ) ) {
645
+ templateUrl = templateUrl ( route . params ) ;
646
+ }
647
+ if ( angular . isDefined ( templateUrl ) ) {
648
+ route . loadedTemplateUrl = $sce . valueOf ( templateUrl ) ;
649
+ template = $templateRequest ( templateUrl ) ;
650
+ }
651
+ }
652
+ return template ;
653
+ }
654
+
655
+
649
656
/**
650
657
* @returns {Object } the current active route, by matching it against the URL
651
658
*/
0 commit comments