Answer the question
In order to leave comments, you need to log in
How to make anchor links with AngularJS?
How to make anchor links work with Angular? the essence of this is a page with code:
<a href="#info">info</a>
<section id="info">
Info....
</section>
Answer the question
In order to leave comments, you need to log in
Everything is not very simple here.
There is such a service: https://docs.angularjs.org/api/ng/service/$anchorScroll
With it, you can do something like this:
// some controller
['$scope', $anchorScroll, function($scope, $anchorScroll) {
$scope.scrollTo = function(id) {
$location.hash(id);
$anchorScroll();
}
}];
$rootScope.$on('$routeChangeSuccess', function(newRoute, oldRoute) {
if($location.hash()) $anchorScroll();
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question