feat(challenge): add a pipe challenge serie

This commit is contained in:
thomas
2022-11-28 14:44:23 +01:00
parent aaeecf5f06
commit 2d61342db5
49 changed files with 1045 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
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; let isFirst = first">
{{ showName(person.name, index) }}
{{ isAllowed(person.age, isFirst) }}
</div>
`,
})
export class AppComponent {
persons = [
{ name: 'Toto', age: 10 },
{ name: 'Jack', age: 15 },
{ name: 'John', age: 30 },
];
showName(name: string, index: number) {
// very heavy computation
return `${name} - ${index}`;
}
isAllowed(age: number, isFirst: boolean) {
if (isFirst) {
return 'always allowed';
} else {
return age > 25 ? 'allowed' : 'declined';
}
}
}