简体   繁体   English

角2重新加载特定的html元素

[英]angular 2 reload specific html element

I just need window.location.reload() for a specific element only. 我只需要window.location.reload()仅用于特定元素。 Specifically, I have a table with many columns. 具体来说,我有一个包含许多列的表。

<p-dataTable #tableRef class="invoice-datatable"></p-dataTable>

When I click the image below, I call refreshTable method which I need it to refresh datatable only. 当我单击下面的图像时,我调用refreshTable方法,该方法只需要刷新数据表即可。

`<img role="button" id="refresh-icon" src="/assets/img/refresh.png (click)="refreshTable(tableRef)">

there is some method to reset the datatable as 有一些方法可以将数据表重置为

export class MyComponent implements OnInit {
    @ViewChild(DataTable) dataTableComponent: DataTable;

    // ...

    refreshTable() {
        this.dataTableComponent.reset();
    }
}

If your dataTable is bound to a model then you just need to update that model with whatever new data necessary when the image is clicked. 如果您的dataTable绑定到模型,则只需要单击该图像时使用所需的任何新数据来更新该模型。

Using .reset() will only reset the filters, sorts, and pagination. 使用.reset()只会重置过滤器,排序和分页。 It doesn't refresh the data, sadly. 不幸的是,它不刷新数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM