Angular 5 Scroll to top on every Route click

后端 未结 18 1857
遇见更好的自我
遇见更好的自我 2020-11-29 17:49

I am using angular 5. I have a dashboard where I have few sections with small content and few sections with so large content that I am facing a problem when changing router

18条回答
  •  粉色の甜心
    2020-11-29 18:27

    If you face this problem in Angular 6, you can fix it by adding the parameter scrollPositionRestoration: 'enabled' to app-routing.module.ts 's RouterModule:

    @NgModule({
      imports: [RouterModule.forRoot(routes,{
        scrollPositionRestoration: 'enabled'
      })],
      exports: [RouterModule]
    })
    

提交回复
热议问题