在docs example中,我正在尝试通过以下方式使用垫子表导出器:
<ng-container>
<mat-card class="mat-card py-0">
<mat-card-header class="label">
<ng-container>
<mat-card-title>{{titoloTabella}}</mat-card-title>
<button mat-button class="align-right" (click)="changeClass()">
<mat-icon [ngClass]="(rotate)?'rotate':'no-rotate'">keyboard_arrow_down</mat-icon>
</button>
</ng-container>
</mat-card-header>
<table mat-table matSort [dataSource]="dataSource" matTableExporter #exporter="matTableExporter">
<ng-container *ngFor="let header of tableConfiguration.tableHeaders; let i = index" matColumnDef="{{ header.headerId }}">
<th mat-header-cell mat-sort-header *matHeaderCellDef>{{ header.headerName }}</th>
<td mat-cell *matCellDef="let row" > {{ row[header.headerId] }} </td>
<ng-container *ngIf="i == 0 && header.isJoinable == 'no'">
<td mat-footer-cell *matFooterCellDef>TOTALE</td>
</ng-container>
<ng-container *ngIf="i > 0">
<td mat-footer-cell *matFooterCellDef>{{ tableFooter[header.headerId] }}</td>
</ng-container>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;" [ngClass]="(collapsed)? 'collapsed-rows': 'no-collapsed-rows' "></tr>
<tr mat-footer-row *matFooterRowDef="displayedColumns"></tr>
</table>
</mat-card>
<button (click)="exporter.exportTable('xlsx')"> EXPORT</button>
</ng-container>
我已经在提供者部分的app.module.ts中导入了MatExporterTabModule。但这是运行应用程序时出现的错误:
RROR错误:未捕获(承诺):错误:模板解析错误:存在 是没有将“ exportAs”设置为“ matTableExporter”(“
答案 0 :(得分:2)
您必须在“导入”部分而不是提供程序中导入此模块。