How to scroll to loaded ui-view

I have a ui-view inside my page. When a button is pressed, the ui-view is loaded and replaced with some HTML. I want the page to scroll to the just loaded part of the page.

Is it possible? thanks in advance

+7
scroll angular-ui-router
source share
2 answers

The ui-router module has been updated to scroll to ui-view by default. You can add the autoscroll="false" attribute on the <div ui-view> to prevent this. The default value is true , which changes to ui when the state changes.

I would think that it should be the other way around when you need to enable autoscrolling, and not disable, but this is the functionality of the updated ui-router.

You can read about it here .

A related Github issue says that the default value is autoscroll="expr" , but I found that expr does nothing and that the default value is autoscroll="true" (which makes more sense).

+23
source share

When you change the route, it will scroll to the top of the page.

  $scope.$on('$routeChangeSuccess', function () { window.scrollTo(0, 0); }); 

put this code on your controller. (Change the value according to your requirements)

+2
source share

All Articles