mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-22 13:21:51 +00:00
fix(docModuleComponents): implement anchor scroll when content added
When navigating to URLs such as docs.angularjs.org/api/ng#filter, the browser was not able to navigate to the named anchor, "filter," because the anchor did not yet exist in the DOM. This fix uses the $anchorScroll service to automatically scroll to the right place when the content has been added to the page. Fixes #4703
This commit is contained in:
parent
56d0917799
commit
eb51b024c9
1 changed files with 20 additions and 18 deletions
|
|
@ -207,7 +207,7 @@ docsApp.directive.sourceEdit = function(getEmbeddedTemplate) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
docsApp.directive.docModuleComponents = ['sections', function(sections) {
|
docsApp.directive.docModuleComponents = function() {
|
||||||
return {
|
return {
|
||||||
template: ' <div class="component-breakdown">' +
|
template: ' <div class="component-breakdown">' +
|
||||||
' <h2>Module Components</h2>' +
|
' <h2>Module Components</h2>' +
|
||||||
|
|
@ -228,7 +228,8 @@ docsApp.directive.docModuleComponents = ['sections', function(sections) {
|
||||||
scope : {
|
scope : {
|
||||||
module : '@docModuleComponents'
|
module : '@docModuleComponents'
|
||||||
},
|
},
|
||||||
controller : ['$scope', function($scope) {
|
controller : ['$scope', '$anchorScroll', '$timeout', 'sections',
|
||||||
|
function($scope, $anchorScroll, $timeout, sections) {
|
||||||
var validTypes = ['property','function','directive','service','object','filter'];
|
var validTypes = ['property','function','directive','service','object','filter'];
|
||||||
var components = {};
|
var components = {};
|
||||||
angular.forEach(sections.api, function(item) {
|
angular.forEach(sections.api, function(item) {
|
||||||
|
|
@ -246,9 +247,10 @@ docsApp.directive.docModuleComponents = ['sections', function(sections) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$scope.components = components;
|
$scope.components = components;
|
||||||
|
$timeout($anchorScroll, 0, false);
|
||||||
}]
|
}]
|
||||||
};
|
};
|
||||||
}]
|
};
|
||||||
|
|
||||||
docsApp.directive.docTutorialNav = function(templateMerge) {
|
docsApp.directive.docTutorialNav = function(templateMerge) {
|
||||||
var pages = [
|
var pages = [
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue