From ec2db151336a4eeb44d7f6fb59e9411416ee2cf2 Mon Sep 17 00:00:00 2001 From: Pete Bacon Darwin Date: Wed, 30 Oct 2013 21:57:53 +0000 Subject: [PATCH] chore(docs/docModuleComponents): allow browser to scroll to anchors This directive, in the documentation application, creates new HTML that contains anchors. If we link to one of these anchors we need to give the browser the opportunity to scroll to them after they have been rendered. An example of such an anchor would be http://docs.angularjs.org/api/ng#directive --- docs/src/templates/js/docs.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/docs/src/templates/js/docs.js b/docs/src/templates/js/docs.js index 70c5c8882ad6..c6b6ad760ebe 100644 --- a/docs/src/templates/js/docs.js +++ b/docs/src/templates/js/docs.js @@ -207,7 +207,7 @@ docsApp.directive.sourceEdit = function(getEmbeddedTemplate) { } }; -docsApp.directive.docModuleComponents = ['sections', function(sections) { +docsApp.directive.docModuleComponents = ['sections', '$anchorScroll', '$timeout', function(sections, $anchorScroll, $timeout) { return { template: '
' + '

Module Components

' + @@ -246,9 +246,14 @@ docsApp.directive.docModuleComponents = ['sections', function(sections) { } }); $scope.components = components; - }] + }], + link: function() { + // This directive creates new HTML that contains anchors. We need to give the browser the + // opportunity to scroll to them after they have been rendered. + $timeout($anchorScroll); + } }; -}] +}]; docsApp.directive.docTutorialNav = function(templateMerge) { var pages = [