This is an extremely frustrating issue. I'm done with my application other then this one last thing. I've been listening for changes on the router, and trying to have it autoscroll to the top upon that change. I've literally tried 10 different solutions on Google and nothing has any effect. I know it's related to the router, but I can't figure out why exactly it won't scroll. Here is the code I'm currently using.
app.component.ts
this.router.events.filter(event => event instanceof NavigationEnd).subscribe(event => {
window.scroll(0, 0);
});
app.component.html
<div class="mainbody bgc-white">
<router-outlet></router-outlet>
</div>
I've tried several variations of this, specifically grabbing the router-outlet element with ElementRef and setting scrollTop = 0, but that had no effect either. Also tried using document.body and that had no effect. What am I missing here?