Files
angular-challenges/apps/angular/pipe-easy/src/app/app.component.ts
2023-10-18 14:08:15 +02:00

22 lines
477 B
TypeScript

import { NgFor } from '@angular/common';
import { Component } from '@angular/core';
@Component({
standalone: true,
imports: [NgFor],
selector: 'app-root',
template: `
<div *ngFor="let person of persons; let index = index">
{{ heavyComputation(person, index) }}
</div>
`,
})
export class AppComponent {
persons = ['toto', 'jack'];
heavyComputation(name: string, index: number) {
// very heavy computation
return `${name} - ${index}`;
}
}