-
Hi, i am trying to pass a table cells template to a table component, but the rows are not getting rendered. <app-table
[columns]="['KEY1', 'KEY2', 'KEY3']"
[columnTemplate]="test"
></app-table>
<ng-template #test>
<td *tuiCell="'KEY1'" tuiTd>template1</td>
<td *tuiCell="'KEY2'" tuiTd>template2</td>
<td *tuiCell="'KEY3'" tuiTd>template3</td>
</ng-template> The table component receives the template as <table tuiTable [columns]="columns" class="table">
<thead tuiThead>
<tr tuiThGroup>
<th *tuiHead="'KEY1'" tuiTh>KEY1</th>
<th *tuiHead="'KEY2'" tuiTh>KEY2</th>
<th *tuiHead="'KEY3'" tuiTh>KEY3</th>
</tr>
</thead>
<tbody tuiTbody [data]="data">
<tr *ngFor="let item of data" tuiTr>
<ng-container *polymorpheusOutlet="columnTemplate as template">{{
template
}}</ng-container>
</tr>
<tr *ngFor="let item of data" tuiTr>
<td *tuiCell="'KEY1'" tuiTd>{{ item.key1 }}</td>
<td *tuiCell="'KEY2'" tuiTd>{{ item.key2 }}</td>
<td *tuiCell="'KEY3'" tuiTd>{{ item.key3 }}</td>
</tr>
</tbody>
</table> Am i doing something terrible wrong, or is this use case not supported by the table? Every help is appreciated! Thank you very much |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
That's because directives are connected together with DI, and in your case they are instantiated away from the table itself. I think this might get fixed in 4.0, once polymorpheus starts passing injector to templates. In current version it is impossible due to Angular 12. |
Beta Was this translation helpful? Give feedback.
That's because directives are connected together with DI, and in your case they are instantiated away from the table itself. I think this might get fixed in 4.0, once polymorpheus starts passing injector to templates. In current version it is impossible due to Angular 12.