mirror of
https://github.com/Raghu-Ch/angular-challenges.git
synced 2026-02-10 21:03:03 -05:00
refactor: move libs
This commit is contained in:
1
libs/shared/ui/src/index.ts
Normal file
1
libs/shared/ui/src/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { TableComponent } from './lib/table.component';
|
||||
29
libs/shared/ui/src/lib/table.component.ts
Normal file
29
libs/shared/ui/src/lib/table.component.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { NgFor, NgTemplateOutlet } from '@angular/common';
|
||||
import { Component, ContentChild, Input, TemplateRef } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'table',
|
||||
standalone: true,
|
||||
imports: [NgTemplateOutlet, NgFor],
|
||||
template: `
|
||||
<thead>
|
||||
<ng-container *ngTemplateOutlet="headerTemplate"></ng-container>
|
||||
</thead>
|
||||
<tbody *ngFor="let item of items">
|
||||
<ng-container
|
||||
*ngTemplateOutlet="
|
||||
bodyTemplate;
|
||||
context: { $implicit: item }
|
||||
"></ng-container>
|
||||
</tbody>
|
||||
`,
|
||||
})
|
||||
export class TableComponent<T> {
|
||||
@Input() items!: T[];
|
||||
|
||||
@ContentChild('header', { read: TemplateRef })
|
||||
headerTemplate!: TemplateRef<void>;
|
||||
|
||||
@ContentChild('body', { read: TemplateRef })
|
||||
bodyTemplate!: TemplateRef<{ $implicit: T }>;
|
||||
}
|
||||
Reference in New Issue
Block a user