scroll to top on route change

This commit is contained in:
tykayn 2021-04-25 11:58:58 +02:00 committed by Baptiste Lemoine
parent 0c08e802c9
commit 74a928800e
1 changed files with 9 additions and 0 deletions

View File

@ -6,6 +6,7 @@ import { environment } from '../environments/environment';
import { Theme } from './core/enums/theme.enum';
import { LanguageService } from './core/services/language.service';
import { ThemeService } from './core/services/theme.service';
import { NavigationEnd, Router } from '@angular/router';
@Component({
selector: 'app-root',
@ -21,12 +22,20 @@ export class AppComponent implements OnInit, OnDestroy {
private themeSubscription: Subscription;
constructor(
private router: Router,
private titleService: Title,
private themeService: ThemeService,
private languageService: LanguageService // private mockingService: MockingService
) {}
ngOnInit(): void {
this.router.events.subscribe((evt) => {
if (!(evt instanceof NavigationEnd)) {
return;
}
window.scrollTo(0, 0);
});
if (!environment.production) {
this.appTitle += ' [DEV]';
}