Angular 6 - Keep scroll position when the route changes

后端 未结 4 2098
萌比男神i
萌比男神i 2021-01-04 12:52

Previous Behavior:

Changing the route or navigation path would not affect the scroll position when navigating to another route. I.e the contents can

4条回答
  •  青春惊慌失措
    2021-01-04 13:28

    Seems like setting 'scrollPositionRestoration' to disabled fixes it

    RouterModule.forRoot(
      appRoutes,
      { scrollPositionRestoration: 'disabled' } // <-- HERE
    )
    

    See https://angular.io/api/router/ExtraOptions

提交回复
热议问题