How to implement Bootstrap 4 for Angular 2 ngb-pagination

前端 未结 3 719
一整个雨季
一整个雨季 2021-02-02 15:57

I have a Angular2 app with a component where I have a table. Table is generated via *ngFor directive. Each row of the table

3条回答
  •  误落风尘
    2021-02-02 16:37

    it's my working solution. API for ngb-pagination: https://ng-bootstrap.github.io/#/components/pagination

        ...
    
    
    

    In your component you need some like that. Don't forget set your variable in constructor:

      itemsPerPage: number;
      totalItems: any;
      page: any;
      previousPage: any;
    
      ...
      loadPage(page: number) {
        if (page !== this.previousPage) {
          this.previousPage = page;
          this.loadData();
        }
      }
      ...
    
      loadData() {
        this.dataService.query({
          page: this.page - 1,
          size: this.itemsPerPage,
        }).subscribe(
          (res: Response) => this.onSuccess(res.json(), res.headers),
          (res: Response) => this.onError(res.json())
          )
      }
    

提交回复
热议问题