forked from tomalaforge/angular-challenges
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.component.ts
More file actions
29 lines (28 loc) · 735 Bytes
/
Copy pathapp.component.ts
File metadata and controls
29 lines (28 loc) · 735 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { CardComponent } from './card.component';
@Component({
imports: [CardComponent],
selector: 'app-root',
template: `
@for (card of cardsArr; track card.title) {
<app-card>
<div>{{ card.title }}</div>
@if (card.message) {
<div>{{ card.message }}</div>
} @else {
<div>Aucun message</div>
}
</app-card>
}
`,
host: {
class: 'p-4 block flex flex-col gap-1',
},
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class AppComponent {
cardsArr: { title: string; message?: string }[] = [
{ title: 'Titre 1', message: 'Message1' },
{ title: 'Titre 2' },
];
}