我有导出表格的要求,我使用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');
}