mirror of
https://github.com/Raghu-Ch/angular-challenges.git
synced 2026-02-10 12:53:03 -05:00
refactor(pipe-easy): update component & comments
This commit is contained in:
@@ -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}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user