@@ -5,11 +5,19 @@ var docsApp = {
5
5
filter : { }
6
6
} ;
7
7
8
- docsApp . controller . DocsVersionsCtrl = [ '$scope' , '$window' , 'NG_VERSIONS' , 'NG_VERSION' , function ( $scope , $window , NG_VERSIONS , NG_VERSION ) {
8
+ docsApp . controller . DocsVersionsCtrl = [ '$scope' , '$rootScope' , '$ window', 'NG_VERSIONS' , 'NG_VERSION' , function ( $scope , $rootScope , $window , NG_VERSIONS , NG_VERSION ) {
9
9
$scope . docs_versions = NG_VERSIONS ;
10
10
$scope . docs_version = NG_VERSIONS [ 0 ] ;
11
+
11
12
$scope . jumpToDocsVersion = function ( version ) {
12
- $window . location = version . url ;
13
+ var currentPagePath = '' ;
14
+
15
+ // preserve URL path when switching between doc versions
16
+ if ( angular . isObject ( $rootScope . currentPage ) && $rootScope . currentPage . section && $rootScope . currentPage . id ) {
17
+ currentPagePath = '/' + $rootScope . currentPage . section + '/' + $rootScope . currentPage . id ;
18
+ }
19
+
20
+ $window . location = version . url + currentPagePath ;
13
21
} ;
14
22
} ] ;
15
23
@@ -645,7 +653,7 @@ docsApp.serviceFactory.sections = ['NG_PAGES', function sections(NG_PAGES) {
645
653
} ] ;
646
654
647
655
648
- docsApp . controller . DocsController = function ( $scope , $location , $window , $cookies , sections ) {
656
+ docsApp . controller . DocsController = function ( $scope , $rootScope , $ location, $window , $cookies , sections ) {
649
657
$scope . fold = function ( url ) {
650
658
if ( url ) {
651
659
$scope . docs_fold = '/notes/' + url ;
@@ -736,9 +744,9 @@ docsApp.controller.DocsController = function($scope, $location, $window, $cookie
736
744
sectionName = SECTION_NAME [ sectionId ] || sectionId ,
737
745
page = sections . getPage ( sectionId , partialId ) ;
738
746
739
- $scope . currentPage = sections . getPage ( sectionId , partialId ) ;
747
+ $rootScope . currentPage = sections . getPage ( sectionId , partialId ) ;
740
748
741
- if ( ! $scope . currentPage ) {
749
+ if ( ! $rootScope . currentPage ) {
742
750
$scope . partialTitle = 'Error: Page Not Found!' ;
743
751
}
744
752
0 commit comments