DataTable - Simple table component with sorting and pagination for Angular2

Module License: MIT

Added by: Sam Deering





Stars: 52

Watchers: 52

Forks: 34

Module Description

Table component with sorting and pagination for Angular2

npm version Build Status Code Climate Test Coverage npm downloads


Check live demo in plunker


npm i -S angular2-datatable

Usage example


import {NgModule} from "@angular/core";
import {DataTableModule} from "angular2-datatable";

    imports: [
export class AppModule {



<table class="table table-striped" [mfData]="data" #mf="mfDataTable" [mfRowsOnPage]="5">
        <th style="width: 20%">
            <mfDefaultSorter by="name">Name</mfDefaultSorter>
        <th style="width: 50%">
            <mfDefaultSorter by="email">Email</mfDefaultSorter>
        <th style="width: 10%">
            <mfDefaultSorter by="age">Age</mfDefaultSorter>
        <th style="width: 20%">
            <mfDefaultSorter by="city">City</mfDefaultSorter>
    <tr *ngFor="let item of">
        <td class="text-right">{{item.age}}</td>
        <td>{{ | uppercase}}</td>
        <td colspan="4">
            <mfBootstrapPaginator [rowsOnPageSet]="[5,10,25]"></mfBootstrapPaginator>


mfData directive

  • selector: table[mfData]
  • exportAs: mfDataTable
  • inputs
    • mfData: any[] - array of data to display on table
    • mfRowsOnPage: number - number of rows should be displayed on page (default: 1000)
    • mfActivePage: number - page number should be displayed on init (default: 1)

mfDefaultSorter component

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

mfBootstrapPaginator 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: mfBootstrapPaginator
  • inputs
    • rowsOnPageSet: number - specify values for buttons to change number of diplayed rows

Module stats last updated: 2018-01-17 16:00:02

Disclaimer: Some data on this page may have been gathered from the authors GitHub respository. If you see any mistakes or outdated information please let us know. Thanks!