动态调用子组件方法

时间:2018-08-09 08:32:54

标签: angular viewchild

我需要导出使用ngFor展示了自定义表格的表格。

当我尝试分别导出每个表时,我得到了错误的结果(每次仅导出一个表),我曾向ViewChildren帮助。

我的代码如下所示

<div ngFor="let eachObj of objList:let i=index;">
    <button (click)="exportReport(i)">Export</button>
    <myTable [data]="eachObj"></myTable>
</div>

    @ViewChildren(MyCustomTable) tables: QueryList<MyCustomTable>;
        exportReport(i:number){
        let mytables: MyCustomTable[] = this.tables.toArray();
        mytables[i].exportMyTable('pdf');
   }

1 个答案:

答案 0 :(得分:0)

我的方法是正确的,我坚持使用其他东西

相关问题