new angular router - autoscroll equivalent

307 Views Asked by At

ui-router and the 1.4 angular router supported autoscroll="true" to enable the page to scroll to top of page on navigation to another route. Does anyone know how to do this with the new angular router?

ng-outlet does not appear to have an autoscroll property and the router itself does not appear to have any events I can listen to so I can hook this up manually.

1

There are 1 best solutions below

0
On

A manual way of doing this is:

$rootScope.$on('$locationChangeSuccess', function() {
  document.body.scrollTop = document.documentElement.scrollTop = 0;
});