refactor(pipe-easy): update component & comments

This commit is contained in:
Sven Brodny
2024-02-16 09:08:20 +01:00
parent dcf80b54db
commit 2f18c6dcde

View File

@@ -7,15 +7,16 @@ import { Component } from '@angular/core';
selector: 'app-root', selector: 'app-root',
template: ` template: `
<div *ngFor="let person of persons; let index = index"> <div *ngFor="let person of persons; let index = index">
{{ heavyComputation(person, index) }} {{ numberedPerson(person, index) }}
</div> </div>
`, `,
}) })
export class AppComponent { export class AppComponent {
persons = ['toto', 'jack']; // TODO: untyped array?
persons = ['toto', 'jack', 'samuel', 'steve'];
heavyComputation(name: string, index: number) { // TODO: very heavy computation, replace this function with a pipe
// very heavy computation numberedPerson(name: string, index: number) {
return `${name} - ${index}`; return `${index + 1}. ${name}`;
} }
} }