How to reset scroll position on a route change?

前端 未结 2 719
半阙折子戏
半阙折子戏 2021-02-07 01:43

I spend my first couple of hours with Angular JS and I am trying to write a SPA with it. However, on changing route, the scroll position remains at its current position after ch

2条回答
  •  攒了一身酷
    2021-02-07 01:54

    As per the ngView documentation:

    autoscroll(optional) string:

    Whether ngView should call $anchorScroll to scroll the viewport after the view is updated.

    So all you have to do is change your ng-view call to turn on autoscroll like so:

提交回复
热议问题