Reputation: 2838
When I change route and go to a page where there's the agm-map
I can't scroll the window to top.
I've tried using
<router-outlet (activate)="onActivate($event)"></router-outlet>
and then in onActivate
:
onActivate(event) {
window.scroll(0, 0);
}
I've also tried
ngAfterViewInit(){
window.scrollTo(0, 0);
}
and
this.router.events.subscribe((evt) => {
if (!(evt instanceof NavigationEnd)) {
return;
}
window.scrollTo(0, 0);
});
inside ngOnInit but it doesn't work: I always land on the map when navigating to the page, and not at the top.
Upvotes: 0
Views: 160