作为对该问题的继续:
angular primeng p-table pagination not working
我需要一种从TypeScript触发html方法的方法。在问题的示例中,我需要一种运行方式
table.reset()
来自我的TypeScript。这样做的原因是,每当使用其他链接(菜单)并且每次更改显示内容时,都会调用我当前的组件。
我了解到,为了初始化分页器字段,我需要使用reset()
方法-但是我的问题是如何触发此更改。
第一次没有问题,因为我将其添加到了我拥有的GET按钮中,但是当再次使用菜单时,我不想按get按钮(我正在使用
ngAfterContentChecked()
答案 0 :(得分:1)
假设这是您的表格:
<p-table #tt [value]="testdata" class="test-data" [lazy]="true"
(onLazyLoad)="loadDataLazily($event)"
[paginator]="true" [rows]="3" [totalRecords]="totalRecords">
要在组件文件中重置它,请按以下方式使用它:
import { Table } from '../../../../node_modules/primeng/components/table/table';
export class TableComponent{
@ViewChild('tt') tt: Table;
resetTable(){
this.tt.reset();
}
}