angular - 从 ts 页面重置 p 表

标签 angular typescript primeng

我正在使用 Primeng table在向其中添加数据后,我想重置数据 - 这样它就会显示新数据。
在 table 上,我使用“刷新”按钮,调用 dt.reset()

html

<p-table #dt [value]="pagedTasks">
..
<p-button icon="fa fa-refresh" iconPos="left" (click)="dt.reset()"></p-button>

如果我手动单击按钮,数据会刷新,我试图模仿相同的功能,但来自 ts页。

ts
..
import { TableModule } from 'primeng/table';
..
export class RenderQueueComponent implements OnInit {
     @ViewChild(TableModule) dt: TableModule;
     ..

  refresh() {
    this.dt.reset(); // property "reset" does not exist on type "TableModule"
  }
}
refresh 功能正在从其他组件调用,因此此处未显示该调用。

我怎样才能做到这一点?

最佳答案

不知道为什么,但我改变了

import { TableModule } from 'primeng/table'; 

到:
import { Table } from 'primeng/table'; 

Table 而不是 TableModule

它开始工作了,这是为什么?

关于angular - 从 ts 页面重置 p 表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51138903/

相关文章:

angular - 类型错误 : OrbitControls is not a constructor in angular2

angular - 为什么 PrimeNG p-calendar 不显示日期值?

css - 如何在primeng中的卡住和解冻列表中设置不同的列样式和宽度

windows - 如何为 Windows 或 Mac 或 Linux 系统发布 Electron 应用程序?

angular - 使用不同名称的管道

javascript - 如何在 UI Angular 2 中填充 json 对象

javascript - 类型错误和短路评估?

typescript - 应该如何使用 TypeScript 编译器 API 的 'module resolution cache'?

typescript - 用于right = | _a |的Rust泛型类型实现| b | b

angular - 如何在DataTable中使用带有命令和参数的Primeng菜单?