Я хочу создать новый «слой» между моими шаблонами и TurboTable PrimeNg, чтобы использовать дополнительные функции и возможности, которые я пишу, поэтому я хочу передать два ng-template
моему собственному компоненту, а от него - p-table
, но он не работает.
In my app.component.html
:
<my-table>
<ng-template #tableHeader pTemplate="header">
<tr>
<th>Vin</th>
<th>Color</th>
<th>Year</th>
</tr>
</ng-template>
<ng-template #tableBody pTemplate="body" let-rowData>
<tr>
<td>{{rowData.vin}}</td>
<td>{{rowData.color}}</td>
<td>{{rowData.year}}</td>
</tr>
</ng-template>
</my-table>
In my-table.component.html
:
<p-table [value]="cars" sortField="brand" sortMode="single">
<ng-template [ngTemplateOutlet]="tableHeader" ></ng-template>
<ng-template [ngTemplateOutlet]="tableBody"></ng-template>
</p-table>
В my-table.component.ts
есть такие:
@ContentChild('tableHeader')
private tableHeader: TemplateRef<any>;
@ContentChild('tableBody')
private tableBody: TemplateRef<any>;
Ошибка, которую я получаю:
ERROR TypeError: Cannot read property 'vin' of undefined.
Почему p-table
не может использовать let-rowData
из app.component.html
? Есть какое-нибудь решение?