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..ba519ab03 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,14 @@
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',
+ scrollPositionRestoration: '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 6ef9bc2b6..a28d7f8ea 100644
--- a/apps/angular/21-anchor-navigation/src/app/home.component.ts
+++ b/apps/angular/21-anchor-navigation/src/app/home.component.ts
@@ -5,14 +5,18 @@ import { NavButtonComponent } from './nav-button.component';
imports: [NavButtonComponent],
selector: 'app-home',
template: `
- Foo Page
+
+ 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 7a22c7f38..3da791a1c 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,10 +1,12 @@
/* eslint-disable @angular-eslint/component-selector */
import { Component, input } from '@angular/core';
+import { RouterLink } from '@angular/router';
@Component({
selector: 'nav-button',
+ imports: [RouterLink],
template: `
-
+
`,
@@ -13,5 +15,6 @@ import { Component, input } from '@angular/core';
},
})
export class NavButtonComponent {
- href = input('');
+ routerLink = input('');
+ fragment = input(undefined);
}
diff --git a/apps/angular/8-pure-pipe/src/app/app.component.ts b/apps/angular/8-pure-pipe/src/app/app.component.ts
index 930fe1313..42799f248 100644
--- a/apps/angular/8-pure-pipe/src/app/app.component.ts
+++ b/apps/angular/8-pure-pipe/src/app/app.component.ts
@@ -1,18 +1,15 @@
import { Component } from '@angular/core';
+import { ShowIndexPipe } from './pipe/show-index.pipe';
@Component({
selector: 'app-root',
+ imports: [ShowIndexPipe],
template: `
@for (person of persons; track person) {
- {{ heavyComputation(person, $index) }}
+ {{ person | showIndex: $index }}
}
`,
})
export class AppComponent {
persons = ['toto', 'jack'];
-
- heavyComputation(name: string, index: number) {
- // very heavy computation
- return `${name} - ${index}`;
- }
}
diff --git a/apps/angular/8-pure-pipe/src/app/pipe/show-index.pipe.ts b/apps/angular/8-pure-pipe/src/app/pipe/show-index.pipe.ts
new file mode 100644
index 000000000..628ab5128
--- /dev/null
+++ b/apps/angular/8-pure-pipe/src/app/pipe/show-index.pipe.ts
@@ -0,0 +1,10 @@
+import { Pipe, PipeTransform } from '@angular/core';
+
+@Pipe({
+ name: 'showIndex',
+})
+export class ShowIndexPipe implements PipeTransform {
+ transform(value: string, index: number): string {
+ return `${value} ${index}`;
+ }
+}