There some solutions, make sure to check them all :)

The router outlet will emit the activate event any time a new component is being instantiated, so we could use (activate) to scroll (for example) to the top:


<router-outlet (activate)="onActivate($event)" ></router-outlet>


onActivate(event) {
    //or document.body.scrollTop = 0;
    //or document.querySelector('body').scrollTo(0,0)

or using this answer to smooth scroll

onActivate(event) {
        let scrollToTop = window.setInterval(() => {
            let pos = window.pageYOffset;
            if (pos > 0) {
                window.scrollTo(0, pos - 20); // how far to scroll on each step
            } else {
        }, 16);

If you wish to be selective, say not every component should trigger the scrolling, you can check it:

onActivate(e) {
    if ("login"{ // for example

Since Angular6.1, we can also use { scrollPositionRestoration: 'enabled' } on eagerly loaded modules and it will be applied to all routes:

RouterModule.forRoot(appRoutes, { scrollPositionRestoration: 'enabled' })

It will also do the smooth scrolling. However this has the inconvenient for doing it on every routing.

An other solution is to do the top scrolling on router animation. Add this in every transition where you want to scroll to the top:

query(':enter, :leave', style({ position: 'fixed' }), { optional: true }),