I have tried autoscroll="false"
on the router-outlet
but does't seem to work, is there any default method
of angular2 for doing the same without using any third party library?
here is a more neat way to do it:
this.router.events.subscribe((ev:any) => {
if (ev instanceof NavigationEnd) {
window.scrollTo(0, 0);
}
});
You could do this in your router configuration. This is likely to be the norm in future versions as suggested here.
RouterModule.forRoot(routes, {scrollPositionRestoration: 'enabled'})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With