当Angular 4数据表显示记录时,记录计数未显示,我在此处访问https://www.npmjs.com/package/angular-4-data-table。这个插件是Angular 2数据表的一个分支:https://ggmod.github.io/angular-2-data-table-demo/,所以我假设该表具有正确的页脚信息,如https://ggmod.github.io/angular-2-data-table-demo/。
html模板
<p>
<button class="btn primary"><a routerLink="./new">New</a></button>
</p>
<p>
<input #query (keyup)="filter(query.value)" class="form-control" placeholder="Search...">
</p>
<data-table
[items]="items"
[itemCount] = "itemCount"
(reload) = "reloadItems($event)"
>
<data-table-column
[property] = "'title'"
[header] = "'Title'"
[sortable] = "true"
[resizable] = "true"
></data-table-column>
<data-table-column
[property] = "'price'"
[header] = "'Price'"
[sortable] = "true"
[resizable] = "true"
>
<ng-template #dataTableCell let-item="item">
{{item.price | currency:'USD':true }}
</ng-template>
</data-table-column>
<data-table-column
[property] = "'$id'"
>
<ng-template #dataTableCell let-item="item">
<a [routerLink]="['./', item._id]">Edit</a>
</ng-template>
</data-table-column>
</data-table>
&#13;
在我的打字稿文件中,我检查过以确保始终定义itemCount。
private initializeTable(products: Product[]) {
this.products = products;
this.tableResource = new DataTableResource(products);
this.tableResource.query({offset: 0})
.then(items => this.items = items);
this.tableResource.count()
.then (count => {
alert('count ' + count);
this.itemCount = count;
});
}
&#13;