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

1.1k Views Asked by At

Is it possible to use Carousel and utilize my pagination on table or anything relate on auto scroll table page ?

I've tried implement carousel but it seems not work at all.

enter image description here

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>

then, my 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;
})

There is bonus from me if anyone can help, thanks

1

There are 1 best solutions below

0
Zigor_de_diofior On

you can use ngx-pagination to do your pagination is very simple to use. install by : npm install ngx-pagination --save

example in the following link enter link description here

regards.