diff --git a/apps/angular/21-anchor-navigation/src/app/app.config.ts b/apps/angular/21-anchor-navigation/src/app/app.config.ts
index 66ab7f73f..e9f3cfdcd 100644
--- a/apps/angular/21-anchor-navigation/src/app/app.config.ts
+++ b/apps/angular/21-anchor-navigation/src/app/app.config.ts
@@ -1,6 +1,13 @@
import { ApplicationConfig } from '@angular/core';
-import { provideRouter } from '@angular/router';
+import { provideRouter, withInMemoryScrolling } from '@angular/router';
import { appRoutes } from './app.routes';
export const appConfig: ApplicationConfig = {
- providers: [provideRouter(appRoutes)],
+ providers: [
+ provideRouter(
+ appRoutes,
+ withInMemoryScrolling({
+ anchorScrolling: 'enabled',
+ }),
+ ),
+ ],
};
diff --git a/apps/angular/21-anchor-navigation/src/app/home.component.ts b/apps/angular/21-anchor-navigation/src/app/home.component.ts
index 522b2af6d..10c1e1424 100644
--- a/apps/angular/21-anchor-navigation/src/app/home.component.ts
+++ b/apps/angular/21-anchor-navigation/src/app/home.component.ts
@@ -9,11 +9,11 @@ import { NavButtonComponent } from './nav-button.component';
Foo Page
Empty
- Scroll Bottom
+ Scroll Bottom
I want to scroll each
- Scroll Top
+ Scroll Top
`,
})
diff --git a/apps/angular/21-anchor-navigation/src/app/nav-button.component.ts b/apps/angular/21-anchor-navigation/src/app/nav-button.component.ts
index 329239f88..886833b86 100644
--- a/apps/angular/21-anchor-navigation/src/app/nav-button.component.ts
+++ b/apps/angular/21-anchor-navigation/src/app/nav-button.component.ts
@@ -1,18 +1,26 @@
/* eslint-disable @angular-eslint/component-selector */
-import { ChangeDetectionStrategy, Component, input } from '@angular/core';
+import {
+ ChangeDetectionStrategy,
+ Component,
+ input,
+ InputSignal,
+} from '@angular/core';
+import { RouterLink } from '@angular/router';
@Component({
selector: 'nav-button',
template: `
-
+
`,
- changeDetection: ChangeDetectionStrategy.Eager,
+ changeDetection: ChangeDetectionStrategy.OnPush,
+ imports: [RouterLink],
host: {
class: 'block w-fit border border-red-500 rounded-md p-4 m-2',
},
})
export class NavButtonComponent {
- href = input('');
+ public href: InputSignal = input('');
+ public fragment: InputSignal = input('');
}
diff --git a/apps/angular/21-anchor-navigation/src/styles.css b/apps/angular/21-anchor-navigation/src/styles.css
index ead2ca114..8a09a857c 100644
--- a/apps/angular/21-anchor-navigation/src/styles.css
+++ b/apps/angular/21-anchor-navigation/src/styles.css
@@ -1,3 +1,7 @@
-@import "tailwindcss";
+@import 'tailwindcss';
/* You can add global styles to this file, and also import other style files */
+
+html {
+ scroll-behavior: smooth;
+}