Implement server side pagination in angular data-table.

Implement server side pagination in angular data-table.

deepakdanydeepakdany Posts: 1Questions: 1Answers: 0
edited June 2019 in Free community support
<table datatable [dtOptions]="dtOptions" class="row-border hover">
  <thead>
    <tr>
      <th>ID</th>
      <th>First name</th>
      <th>Last name</th>
    </tr>
  </thead>
  <tbody *ngIf="persons?.length != 0">
      <tr *ngFor="let person of persons">
          <td>{{ person.id }}</td>
          <td>{{ person.firstName }}</td>
          <td>{{ person.lastName }}</td>
      </tr>
  </tbody>
  <tbody *ngIf="persons?.length == 0">
    <tr>
      <td colspan="3" class="no-data-available">No data!</td>
    </tr>
  <tbody>
</table>
dtOptions: any = {}

  @Input()persons: Person[]

  constructor() { }

  ngOnInit() {
    this.dtOptions = {
      data: [],
      pagingType: 'full_numbers',
      pageLength: 2,
      responsive: true,
     
    }
  }

  ngOnChanges() {
    if (this.persons) {
      this.dtOptions.data = persons
    }
  }

This is my api end point http://localhost:4200/#/users?page=1&recordSize=2

This discussion has been closed.