Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 错误使用matTableExporter时,没有将“exportAs”设置为“matTableExporter”的指令_Angular_Angular7_Mat Table - Fatal编程技术网

Angular 错误使用matTableExporter时,没有将“exportAs”设置为“matTableExporter”的指令

Angular 错误使用matTableExporter时,没有将“exportAs”设置为“matTableExporter”的指令,angular,angular7,mat-table,Angular,Angular7,Mat Table,从开始,我尝试使用mat table exporter,方法如下: <ng-container> <mat-card class="mat-card py-0"> <mat-card-header class="label"> <ng-container> <mat-card-title>{{titoloTabella}}</mat-card-title>

从开始,我尝试使用mat table exporter,方法如下:

<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的providers部分导入了MateXPorterTable模块。但这是我运行应用程序时遇到的错误:

错误:未捕获承诺:错误:模板分析错误:有 没有将exportAs设置为matTableExporter的指令


您必须在导入部分而不是在提供程序中导入此模块。

MattableExporter从“mat table exporter”导入{MatTableExporterModule};导入:[//其他模块,MatTableExporterModule,]必须导入到您的moduleapp.module或shared.module中。