Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions apps/angular/pipe-easy/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
import { NgFor } from '@angular/common';
import { Component } from '@angular/core';
import { HeavyComputationPipe } from './shared/HeavyComputation.pipe';

@Component({
standalone: true,
imports: [NgFor],
selector: 'app-root',
template: `
<div *ngFor="let person of persons; let index = index">
{{ heavyComputation(person, index) }}
{{ person | heavy: index }}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very good, you could have used the new control flow syntax, but this is not the goal of this challenge.

</div>
`,
imports: [NgFor, HeavyComputationPipe],
})
export class AppComponent {
persons = ['toto', 'jack'];

heavyComputation(name: string, index: number) {
// very heavy computation
return `${name} - ${index}`;
}
}
11 changes: 11 additions & 0 deletions apps/angular/pipe-easy/src/app/shared/HeavyComputation.pipe.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
name: 'heavy',
standalone: true,
})
export class HeavyComputationPipe implements PipeTransform {
transform(name: string, index: number): string {
return `${name} - ${index}`;
}
}