79830881

Date: 2025-11-26 15:28:56
Score: 0.5
Natty:
Report link

This is a version for standalone component (Angular 15+)
You need withInMemoryScrolling: https://angular.dev/api/router/InMemoryScrollingOptions

// app.config.ts
import { ApplicationConfig } from '@angular/core';
import { provideRouter, withInMemoryScrolling } from '@angular/router';
import { appRoutes } from './app.routes';
export const appConfig: ApplicationConfig = {
  providers: [provideRouter(
    appRoutes,
    withInMemoryScrolling({
      scrollPositionRestoration: 'enabled', 
      anchorScrolling: 'enabled',
    })
  )],
};

// your component
 <a routerLink fragment="some-id">Scroll Top</a>
Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: idembele70