-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Expand file tree
/
Copy pathcard.component.ts
More file actions
33 lines (29 loc) · 942 Bytes
/
card.component.ts
File metadata and controls
33 lines (29 loc) · 942 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
30
31
32
33
import { NgTemplateOutlet } from '@angular/common';
import { Component, ContentChild, input, TemplateRef } from '@angular/core';
@Component({
selector: 'app-card',
template: `
<div
class="flex w-fit flex-col gap-3 rounded-md border-2 border-black p-4"
style="background-color: var(--card-bg, transparent)"
[class]="customClass()">
<ng-content select="[card-header]"></ng-content>
<section>
@for (item of list(); track item) {
<ng-container
*ngTemplateOutlet="
itemTemplate;
context: { $implicit: item }
"></ng-container>
}
</section>
<ng-content select="[card-action]"></ng-content>
</div>
`,
imports: [NgTemplateOutlet],
})
export class CardComponent {
readonly list = input<any[] | null>(null);
readonly customClass = input('');
@ContentChild('itemTemplate') itemTemplate!: TemplateRef<any>;
}