我是Angular7和PrimeNG的新手。我不知道如何将表标题作为变量传递:
<p-table [value]="userSrv.items" [title]="table.title">
<ng-template pTemplate="caption" let-title>
{{title}}
</ng-template>
<ng-template pTemplate="header">
<tr>
<th>Name</th>
<th>Email</th>
</tr>
</ng-template>
<ng-template pTemplate="body" let-item>
<tr>
<td>{{item.fullName}}</td>
<td>{{item.email}}</td>
</tr>
</ng-template>
</p-table>
或如何在ngOnInit组件方法上插入动态ngTemplate='caption'
(或其他模板)。
答案 0 :(得分:1)
无需定义[title]="table.title"
或let-title
之类的东西。
您可以以这种方式使用字幕模板:
<ng-template pTemplate="caption">
{{title}}
</ng-template>
查看有效的StackBlitz