-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Expand file tree
/
Copy pathcard.component.ts
More file actions
41 lines (36 loc) · 1.04 KB
/
card.component.ts
File metadata and controls
41 lines (36 loc) · 1.04 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
import { Component, input, output } from '@angular/core';
import { ListItemComponent } from '../list-item/list-item.component';
@Component({
selector: 'app-card',
template: `
<div
class="flex w-fit flex-col gap-3 rounded-md border-2 border-black p-4"
[class]="customClass()">
<ng-content></ng-content>
<section>
@for (item of list(); track item) {
<app-list-item
[name]="displayNameFn()(item)"
[id]="item.id"
(itemDeleted)="itemDeleted.emit($event)"></app-list-item>
}
</section>
<button
class="rounded-sm border border-blue-500 bg-blue-300 p-2"
(click)="addNewItem()">
Add
</button>
</div>
`,
imports: [ListItemComponent],
})
export class CardComponent {
itemDeleted = output<number>();
itemAdded = output<void>();
readonly list = input<any[] | null>(null);
readonly customClass = input('');
readonly displayNameFn = input<(item: any) => string>(() => '');
addNewItem() {
this.itemAdded.emit();
}
}