Skip to content

Commit 466b068

Browse files
committed
feat: set scroll position to top on route change
1 parent 5abe318 commit 466b068

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

src/app/app.config.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';
2-
import { provideRouter } from '@angular/router';
2+
import { provideRouter, withEnabledBlockingInitialNavigation, withInMemoryScrolling } from '@angular/router';
33

44
import { routes } from './app.routes';
55
import { provideHttpClient } from '@angular/common/http';
@@ -8,7 +8,14 @@ import { provideAnimations } from '@angular/platform-browser/animations';
88
export const appConfig: ApplicationConfig = {
99
providers: [
1010
provideZoneChangeDetection({ eventCoalescing: true }),
11-
provideRouter(routes),
11+
provideRouter(
12+
routes,
13+
withEnabledBlockingInitialNavigation(),
14+
withInMemoryScrolling({
15+
scrollPositionRestoration: 'top',
16+
anchorScrolling: 'enabled',
17+
}),
18+
),
1219
provideHttpClient(),
1320
provideAnimations(),
1421
],

0 commit comments

Comments
 (0)