簡體   English   中英

'MatTableDataSource 類型的參數<empelement> ' 不可分配給 'Collection 類型的參數<unknown> '。</unknown></empelement>

[英]Argument of type 'MatTableDataSource<EmpElement>' is not assignable to parameter of type 'Collection<unknown>'.

如果我將 ngx-paginator 添加到 mat table,我將面臨這個問題。 請幫幫我。

   <table mat-table [dataSource]="dataSource| paginate: {itemsPerPage: size, currentPage: p, 
   totalItems: EMP_DATA.length}" class="mat-elevation-z8" matSort>
        
    .
    .
    <pagination-controls (pageChange)="p = $event;paginate(p)"


    [responsive]="true"
    ></pagination-controls>

在 ts 文件中

         size = 10;
         pageIndex = 0;
         p=1;
         dataSource = new MatTableDataSource<EmpElement>(this.EMP_DATA);

          paginate(event: any) {
          this.pageIndex=event;
            }

從錯誤中,我假設 EmpElement 不是數組

更改以下行:

 dataSource = new MatTableDataSource<EmpElement[]>(this.EMP_DATA);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM