Avatar ·

Scrolling page up when changing route in Angular 2+

Hello everyone! I just started learning Angular and encountered a problem. When navigating between pages using `routerLink`, the browser preserves the scroll position, and if I was at the bottom of a long page and then navigate to another page, it also opens at the bottom. This is very inconvenient for users. I'm using Angular 14 with a modular architecture. Here is an example of my routes: ```typescript // app-routing.module.ts const routes: Routes = [ { path: '', component: HomeComponent }, { path: 'products', component: ProductsComponent }, { path: 'about', component: AboutComponent } ]; ``` I navigate using a regular `routerLink` in the template: ```html