diff --git a/docs/app/js/anchor.js b/docs/app/js/anchor.js index 4255ec14408..8cca280079e 100644 --- a/docs/app/js/anchor.js +++ b/docs/app/js/anchor.js @@ -25,7 +25,7 @@ return; } - var anchorEl = $compile('')(scope); + var anchorEl = $compile('')(scope); // Wrap contents inside of the anchor element. anchorEl.append(element.contents()); @@ -40,8 +40,14 @@ * Creates URL from the text content of the element and writes it into the scope. */ function createContentURL() { - var path = scope.$root.$location ? scope.$root.$location.path() : ''; + var path = ''; var name = element.text(); + // Use $window.location.pathname to get the path with the baseURL included. + // $location.path() does not include the baseURL. This is important to support how the docs + // are deployed with baseURLs like /latest, /HEAD, /1.1.13, etc. + if (scope.$root.$window && scope.$root.$window.location) { + path = scope.$root.$window.location.pathname; + } name = name .trim() // Trim text due to browsers extra whitespace. .replace(/'/g, '') // Transform apostrophes words to a single one. @@ -49,7 +55,8 @@ .replace(/-{2,}/g, '-') // Remove repeating dash symbols. .replace(/^-|-$/g, '') // Remove preceding or ending dashes. .toLowerCase(); // Link should be lower-case for accessible URL. - scope.name = path + '#' + name; + scope.name = name; + scope.href = path + '#' + name; } } } diff --git a/docs/app/js/app.js b/docs/app/js/app.js index c9af69728a3..e41dd09a9ca 100644 --- a/docs/app/js/app.js +++ b/docs/app/js/app.js @@ -148,9 +148,9 @@ function(SERVICES, COMPONENTS, DEMOS, PAGES, AngularyticsProvider.setEventHandlers(['GoogleUniversal']); }]) -.run(['$rootScope', '$location', 'Angularytics', function($rootScope, $location, Angularytics) { +.run(['$rootScope', '$window', 'Angularytics', function($rootScope, $window, Angularytics) { Angularytics.init(); - $rootScope.$location = $location; + $rootScope.$window = $window; }]) .factory('menu', [ @@ -453,7 +453,7 @@ function(SERVICES, COMPONENTS, DEMOS, PAGES, $location, $rootScope, $http, $wind type: "link" }; - if (path == '/') { + if (path === '/') { self.selectSection(introLink); self.selectPage(introLink, introLink); return;