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
No answers yet.
Log in to leave an answer
Blogs
Deploying a Kotlin Application on VPS: Step-by-Step Guide
Generics in Kotlin: why they are needed and how to use them
Swift for Machine Learning: Capabilities and Limitations in Practice
Event-driven Architecture in PHP: Writing Asynchronous Code Without Pain