簡體   English   中英

如何使用Angular 6在表格分頁上實現自動幻燈片?

[英]How can i implement auto slide on table pagination using Angular 6?

是否可以使用Carousel並利用我在桌子上的分頁或自動滾動表頁面上的任何內容?

我嘗試過旋轉木馬,但似乎根本不起作用。

在此輸入圖像描述

dashboard.component.html

<div class="row" >
<div eds-tile class="xl-12" style="width: 700px">
    <eds-tile-title>User on Shift</eds-tile-title>
<ngb-carousel *ngIf="carousel">
  <ng-template ngbSlide>
    <table class="table">
      <thead>
       <tr>
       <th *ngFor="let col of tablePresetColumns">
       {{col.content}}
       </th>
       <th></th>
       <th></th>
       </tr>
      </thead>
      <tbody>
        <div *ngIf='!tablePresetData' class="loading large"></div>
       <tr *ngFor="let row of tablePresetData | paginate: { itemsPerPage: 11, currentPage: p }; ">
        <td *ngFor="let cell of row"> {{cell.content}}</td>
       </tr>
      </tbody>
              <pagination-controls (pageChange)="p = $event"></pagination-controls>  
  </table>
  </ng-template>
</ngb-carousel>
</div>

然后,我的dashboard.component.ts

constructor(private activityService: ActivityService, private router: Router) { }
public apiData;
public carousel;
public tables;

ngOnInit() {

this.carousel = [1,2,3,4,5,6,7,8,9,10,11,12].map(()=> 'p:number = ${Math.random()}');

this.activityService.getAchievement().subscribe((res) =>  {
  this.apiData = res;

  var ids = [['Username', 1], ['Role', 2], ['today', 3], ['weekly', 4], ['monthly', 5], ['yearly', 6]],
  result = Object.keys(res).map(o => ids.map(([key, id]) => ({ id, content: res[o][key] })));
  this.tablePresetData = result;
})

如果有人能提供幫助,我會得到獎金,謝謝

您可以使用ngx-pagination進行分頁,使用非常簡單。 安裝方式:npm install ngx-pagination --save

以下鏈接中的示例在此輸入鏈接描述

問候。

暫無
暫無

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

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