December 14, 2019

Auto page scroll to top after moving to new route in angularX

Put the bellow code in your angular app.component.ts for auto page scroll to top after moving to new route in any angular 2+ version.

app.component.ts in constructor() or ngOnInit()

this.router.events.subscribe(route => {
window.scrollTo(0, 0);
})

 

You may also like...