Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I prevent the window from scrolling when changing states with AngularJS UI-Router?

With ui-router whenever the user navigates between states the browser window always scrolls to a seemingly random location. It seems to be worse when there are multiple ui-views in play. How can I prevent this from happening?

like image 421
respectTheCode Avatar asked Nov 17 '25 20:11

respectTheCode


1 Answers

The ui-view autoscroll parameter controls this. By setting autoscroll="false" in all of your ui-views the browser will not scroll when navigating.

http://angular-ui.github.io/ui-router/site/#/api/ui.router.state.directive:ui-view

like image 128
respectTheCode Avatar answered Nov 20 '25 09:11

respectTheCode



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!