0

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.

gatapia
  • 3,574
  • 4
  • 40
  • 48

1 Answers1

1

A manual way of doing this is:

$rootScope.$on('$locationChangeSuccess', function() {
  document.body.scrollTop = document.documentElement.scrollTop = 0;
});
gatapia
  • 3,574
  • 4
  • 40
  • 48