I want that whenever you access a certain route in an Angular application, the view appears from above, that is, with the initial scroll.
I want that whenever you access a certain route in an Angular application, the view appears from above, that is, with the initial scroll.
Adding $anchorScroll()
and injecting it into the controller of your Angular view, will always locate the view at the beginning of the HTML
.controller('viewController', ['$anchorScroll', function ($anchorScroll){
$anchorScroll();
}])
If you are using ng-view you only have to use autoscroll:
<div ng-view autoscroll><div>
So you do not have to inject any service into the controllers.
Example in Plunker