【发布时间】:2021-08-25 14:26:27
【问题描述】:
我在我的模板中使用primeng表,如下所示:
<p-table [paginator]="true" [rows]="10" [showCurrentPageReport]="true"
currentPageReportTemplate="Showing {first} to {last} of {totalRecords} entries" [rowsPerPageOptions]="[10,25,50]"
[value]="histories">
<ng-template pTemplate="header">
<tr>
<th>duration</th>
<th>build id</th>
</tr>
</ng-template>
<ng-template pTemplate="body" let-build>
<tr>
<td [style]="{'word-wrap':'break-word !important'}">
{{ secondsToDhms(build.duration) }}
</td>
<td [style]="{'word-wrap':'break-word !important'}">
{{ build.build_id }}
</td>
</tr>
</ng-template>
<ng-template pTemplate="paginatorleft">
<p-button type="button" icon="pi pi-plus" styleClass="p-button-text"></p-button>
</ng-template>
<ng-template pTemplate="paginatorright">
<p-button type="button" icon="pi pi-cloud" styleClass="p-button-text"></p-button>
</ng-template>
</p-table>
我如何在 p-table 中获取循环元素的索引,因为它不是经典的 ngfor let of,所以我可以稍后测试它是否是在我的模板中隐藏按钮的最后一个元素?
【问题讨论】:
-
这里的 SO 答案应该足够了。 stackoverflow.com/questions/52996750/…