I'm using PrimeNG
12.0.1 and its Table to display data in my Angular
application.
I have separate @Component
which contains <p-table>
in html template. Inside <p-table>
there's ng-template
s to display table parts like pTemplate="colgroup"
, pTemplate="header"
, pTemplate="body"
etc.
I would like to move these parts to separate files to be able to reuse them in new Component
which will also have <p-table>
. How to achieve that to move these elements to other file (Component
?) and have working table?
Below some current code fragments:
<p-table #table [value]="userDataSource.data$ | async" [columns]="displayedColumns" ........>
<ng-template pTemplate="colgroup" let-columns>
<colgroup>
<col *ngFor="let col of columns" [ngStyle]=".........">
</colgroup>
</ng-template>
<ng-template pTemplate="header" let-columns>
<tr>
<ng-container *ngFor="let col of columns">
.........
</ng-container>
</tr>
</ng-template>
<ng-template pTemplate="body" let-row let-columns="columns" let-expanded="expanded">
<tr (click)="rowClicked(row)" class="...........">
<ng-container *ngFor="let column of columns">
................
</ng-container>
</tr>
</ng-template>
</p-table>