trying to use angular material paginator without a table

前端 未结 1 1923
别跟我提以往
别跟我提以往 2021-01-06 08:38

I started with the exact example \"Data table with sorting, pagination, and filtering.\" here https://material.angular.io/components/table/examples It works fine. But

相关标签:
1条回答
  • 2021-01-06 09:20

    You probably already managed to work around that issue but, since I was looking for that, and probably others will too.

    I was facing the same problem, and manage to do it simply by doing the connect in on ngOnInit and using another observable in the view (I only put the thing i changed):

    export class TableOverviewExample implements OnInit {
      obs: Observable<any>;
      ...
    
      ngOnInit(): void {
        ...
        this.obs = this.dataSource.connect();
      }
    }
    

    and in the View:

    <div *ngFor="let row of obs | async" >
    

    You will probably have to manually disconect the datasource, I have not validated that... I just did in:

    ngOnDestroy(): void {
      if (this.dataSource) { this.dataSource.disconnect(); }
    }
    
    0 讨论(0)
提交回复
热议问题