Changing route doesn't scroll to top in the new page

后端 未结 18 2089
北恋
北恋 2020-11-29 15:11

I've found some undesired, at least for me, behaviour when the route changes. In the step 11 of the tutorial http://angular.github.io/angular-phonecat/step-11/app/#/phon

18条回答
  •  广开言路
    2020-11-29 15:24

    The problem is that your ngView retains the scroll position when it loads a new view. You can instruct $anchorScroll to "scroll the viewport after the view is updated" (the docs are a bit vague, but scrolling here means scrolling to the top of the new view).

    The solution is to add autoscroll="true" to your ngView element:

提交回复
热议问题