DataTable component for Angular framework

Usage no npm install needed!

<script type="module">
  import aflorin11DataTable from 'https://cdn.skypack.dev/@aflorin11/data-table';


Table component with sorting and pagination for Angular 7

It is a forked version of @abdulk1/angular-6-datatable.


npm i @aflorin11/data-table --save

Usage example


import {NgModule} from "@angular/core";
import {DataTableModule} from "@aflorin11/data-table";

    imports: [
export class AppModule {



  class="table table-striped"
      <th style="width: 20%">
        <afDefaultSorter by="name">Name</afDefaultSorter>
      <th style="width: 50%">
        <afDefaultSorter by="email">Email</afDefaultSorter>
      <th style="width: 10%">
        <afDefaultSorter by="age">Age</afDefaultSorter>
      <th style="width: 20%">
        <afDefaultSorter by="city">City</afDefaultSorter>
    <tr *ngFor="let item of af.data">
      <td class="text-right">{{item.age}}</td>
      <td>{{item.city | uppercase}}</td>
      <td colspan="4">


afData directive

  • selector: table[afData]
  • exportAs: afDataTable
  • inputs
    • afData: any[] - array of data to display in table
    • afRowsOnPage: number - number of rows should be displayed on page (default: 1000)
    • afActivePage: number - page number (default: 1)
    • afSortBy: any - sort by parameter
    • afSortOrder: string - sort order parameter, "asc" or "desc"
  • outputs
    • afSortByChange: any - sort by parameter
    • afSortOrderChange: any - sort order parameter

afDefaultSorter component

  • selector: afDefaultSorter
  • inputs
    • by: any - specify how to sort data (argument for lodash function _.sortBy )

afBootstrapPaginator component

Displays buttons for changing current page and number of displayed rows using bootstrap template (css for bootstrap is required). If array length is smaller than current displayed rows on page then it doesn't show button for changing page. If array length is smaller than min value rowsOnPage then it doesn't show any buttons.

  • selector: afBootstrapPaginator
  • inputs
    • rowsOnPageSet: number - specify values for buttons to change number of diplayed rows
    • buttons: object = { firstBtn: string, previousBtn: string, nextBtn: string, lastBtn: string } - specify labels for first, previous, next and last buttons