How to use paginator from material angular?

后端 未结 9 1851
清歌不尽
清歌不尽 2020-12-04 11:14

I\'m new to angular and trying to implement pagination in my app. I am trying to use this material component.

With the code below, I can get length,

9条回答
  •  天涯浪人
    2020-12-04 11:29

    Another way to link Angular Paginator with the data table using Slice Pipe.Here data is fetched only once from server.

    View:

     
    //actual data dispaly

    Component

        pageIndex:number = 0;
        pageSize:number = 50;
        lowValue:number = 0;
        highValue:number = 50;       
    
      getPaginatorData(event){
         console.log(event);
         if(event.pageIndex === this.pageIndex + 1){
            this.lowValue = this.lowValue + this.pageSize;
            this.highValue =  this.highValue + this.pageSize;
           }
        else if(event.pageIndex === this.pageIndex - 1){
           this.lowValue = this.lowValue - this.pageSize;
           this.highValue =  this.highValue - this.pageSize;
          }   
           this.pageIndex = event.pageIndex;
     }
    

提交回复
热议问题