Angular Bootstrap table search

Angular Table search - Bootstrap 4 & Material Design

Angular Bootstrap table search are a component which are super fast and easy to use searching functionality dedicated to our tables.

To manipulate table search use one of the options presented below.

Basic example Live Example

        <div class="row">
          <div class="col-md-12 mx-auto">
            <div class="md-form">
              <input type="text" [(ngModel)]="searchText" class="form-control" id="search" mdbInputDirective>
              <label for="search">Search</label>
        <table mdbTable class="z-depth-1">
              <th *ngFor="let head of headElements; let i = index" scope="col">{{head}}
            <tr *ngFor="let el of elements; let i = index">
              <th scope="row">{{}}</th>
              <td class="red-text">{{el.first}}</td>

import { MdbTableService } from 'PATH-TO-MDB-ANGULAR';

import { Component, OnInit } from '@angular/core';

  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss'],
export class AppComponent implements OnInit {

  elements: any = [];
  headElements = ['ID', 'First', 'Last', 'Handle'];

  searchText: string = '';
  previous: string;

  constructor(private tableService: MdbTableService) { }

  @HostListener('input') oninput() {

  ngOnInit() {
    for (let i = 1; i <= 10; i++) {
      this.elements.push({ id: i.toString(), first: 'Wpis ' + i, last: 'Last ' + i, handle: 'Handle ' + i });

    this.elements = this.tableService.getDataSource();
    this.previous = this.tableService.getDataSource();

  searchItems() {
    const prev = this.tableService.getDataSource();

    if (!this.searchText) {
      this.elements = this.tableService.getDataSource();

    if (this.searchText) {
      this.elements = this.tableService.searchLocalDataBy(this.searchText);



Advanced table options

For advanced options of the tables have a look at specific documentation pages listed below.

Table sort

This functionality lets you sort the data of the tables according to any specific columns.

Table editable

Table editable allows you to edit existing data within the table and add new data to the table.

Table pagination

Table with pagination allows you to paginate through your data in the tables

Angular Datatables - API

In this section you will find advanced information about the Table component. You will find out which modules are required in this component, what are the possibilities of configuring the component, and what events and methods you can use in working with it.

Modules used

In order to speed up your application, you can choose to import only the modules you actually need, instead of importing the entire MDB Angular library. Remember that importing the entire library, and immediately afterwards a specific module, is bad practice, and can cause application errors.

              // MDB Angular Pro
              import { WavesModule, TableModule, InputsModule } from 'ng-uikit-pro-standard';

              // MDB Angular Free
              import { WavesModule, TableModule, InputsModule } from 'angular-bootstrap-md';

              // Angular Forms
              import { FormsModule } from '@angular/forms';



Type: MdbTableService


Name Description Example
setDataSource(source: Array<any>) It is used to indicate service an array that stores the data contained in the table. The use of this method is required for the use of results filtering. this.tableService.setDataSource(this.elements)
getDataSource() The method returns an array that has been indicated as the data source of the table. The use of this method is required to filter the results. this.elements = this.tableService.getDataSource()
searchLocalDataBy(searchText: string) The method starts filtering the source array by the character provided as its parameter. The use of this method is required to be able to filter the results. this.elements = this.tableService.searchLocalDataBy(this.searchText)