0

I am facing this issue if i am adding ngx-paginator to mat table. Please help me out.

   <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>

IN ts file

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

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

1 Answers1

0

From the error, I am assuming that EmpElement is not an array

Change below line :

 dataSource = new MatTableDataSource<EmpElement[]>(this.EMP_DATA);
mak15
  • 367
  • 2
  • 12
  • Argument of type 'EmpElement[]' is not assignable to parameter of type 'EmpElement[][]'. Type 'EmpElement' is missing the following properties from type 'EmpElement[]': length, pop, push, concat, and 26 more. – Shruti Jain Apr 28 '21 at 13:09
  • Structure of EmpElement - EMP_DATA: EmpElement[] = [{..............}] – Shruti Jain Apr 28 '21 at 13:10
  • @shruti Jain , I have updated the answer, kindly check now – mak15 Apr 28 '21 at 23:50
  • Hi, but again it shows me error. EmpElement only refers to a type, but is being used as a value here. – Shruti Jain Apr 29 '21 at 04:56