1import { Component, OnInit } from '@angular/core';
2import { Router, NavigationEnd } from '@angular/router';
3
4@Component({
5 selector: 'my-app',
6 template: '<ng-content></ng-content>',
7})
8export class MyAppComponent implements OnInit {
9 constructor(private router: Router) { }
10
11 ngOnInit() {
12 this.router.events.subscribe((evt) => {
13 if (!(evt instanceof NavigationEnd)) {
14 return;
15 }
16 window.scrollTo(0, 0)
17 });
18 }
19}