Show view of AngularJS from above (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.

asked by 12.01.2016 в 20:35

2 answers


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){
answered by 12.01.2016 / 20:57

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

answered by 13.01.2016 в 18:24