-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Expand file tree
/
Copy pathtable.component.ts
More file actions
25 lines (23 loc) · 773 Bytes
/
table.component.ts
File metadata and controls
25 lines (23 loc) · 773 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
import { NgTemplateOutlet } from '@angular/common';
import { Component, contentChild, input, TemplateRef } from '@angular/core';
@Component({
// eslint-disable-next-line @angular-eslint/component-selector
selector: 'table',
imports: [NgTemplateOutlet],
template: `
<thead>
<ng-container *ngTemplateOutlet="headerTemplate()"></ng-container>
</thead>
@for (item of items(); track $index) {
<tbody>
<ng-container
*ngTemplateOutlet="bodyTemplate(); context: { $implicit: item }" />
</tbody>
}
`,
})
export class TableComponent<T> {
items = input.required<T[]>();
headerTemplate = contentChild.required('header', { read: TemplateRef });
bodyTemplate = contentChild.required('body', { read: TemplateRef });
}