Angular 13 Custom Filter Search Pipe Example Tutorial

Angular custom filter search pipe tutorial, In this tutorial, we will explain how to create a custom filter search pipe in the angular application using angular pipe and Bootstrap.

Pipes are handy and help you format the data before displaying it in the View. Pipe are declared with the help of the | symbol.

This symbol defines the Pipe Operator in angular. Throughout this Angular Search Filter tutorial, you will use the pipe symbol to filter the data.

Bootstrap is a robust front-end framework applied to build modern web and mobile applications. It reduces the pain of writing code from scratch for HTML and CSS, most importantly open-source.

Thus, we will use Bootstrap UI in this comprehensive angular search filter example.

Angular 13 Custom Filter Search Pipe Example

  • Create Angular Project
  • Generate Custom Pipe
  • Create Custom Filter Search Pipe
  • Add Search Filter in AppModule
  • Add Dummy Data
  • Implement Filter Search with Custom Pipe
  • Run Angular Application

Create Angular Project

Angular CLI is a command-line interface tool recommended to initialize, develop likewise scaffold the angular application.

npm install -g @angular/cli

Further, use the following command to start installing the new angular app:

ng new ng-form-validaiton

Next, get into the project root:

cd ng-form-validaiton

Disable Strict Angular TypeStrict Errors

The latest version of Angular comes with strict mode, you have to manually disable the strict mode you can set “strict”: false, "noImplicitReturns": false and "strictTemplates": false inside the compilerOptions and angularCompilerOptions in tsconfig.json file.

Generate Custom Pipe in Angular

Open the terminal, use the below command to generate the custom search filter pipe:

ng generate pipe search-filter

Create Custom Filter Search Pipe

The above command manifested the two files inside the app/ directory, hence open search-filter.pipe.ts file on top of that append the following code:

import { Pipe, PipeTransform } from '@angular/core';

  name: 'searchFilter'

export class SearchFilterPipe implements PipeTransform {

  transform(value: any, args?: any): any {
      if(!value)return null;
      if(!args)return value;

      args = args.toLowerCase();

      return value.filter(function(data){
          return JSON.stringify(data).toLowerCase().includes(args);


Register Search Filter in AppModule

In the subsequent step, you have to add search filter, and register within the @NgModule’s declarations array. Thereupon, open and update the app.module.ts file:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';

import { FormsModule } from '@angular/forms';
import { SearchFilterPipe } from './search-filter.pipe';

  declarations: [
  imports: [
  providers: [],
  bootstrap: [AppComponent]

export class AppModule { }

Add Dummy Data

Open app.component.ts file, similarly define the Students array on top of that add the student’s test data.

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

  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']

export class AppComponent {

  public searchFilter: any = '';


  Students = [{
      "id": 1,
      "name": "Nathaniel Graham",
      "email": ""
      "id": 2,
      "name": "Avery Adams",
      "email": ""
      "id": 3,
      "name": "Mario Stevens",
      "email": ""
      "id": 4,
      "name": "Constance Beck",
      "email": ""
      "id": 5,
      "name": "Jimmie Little",
      "email": ""
      "id": 6,
      "name": "Avery Matthews",
      "email": ""
      "id": 7,
      "name": "Pat Sutton",
      "email": ""
      "id": 8,
      "name": "Danny Crawford",
      "email": ""
      "id": 9,
      "name": "Pearl Mccoy",
      "email": ""
      "id": 10,
      "name": "Flenn Wallace",
      "email": ""


Implement Filter Search with Custom Pipe

In this step, you will implement the angular custom pipe and filter the data. Hence, open and update the app.component.html file.

<div class="container mt-5" style="max-width: 550px;">

  <div class="form-group">
    <input type="text" class="form-control mb-4" placeholder="Search" [(ngModel)]="query" id="listSearch">

  <div class="card mb-1" *ngFor="let data of Students | searchFilter: query">
    <div class="card-body">
      <h5 class="card-title">{{}}</h5>
      <h6 class="card-subtitle mb-2 text-muted">{{}}</h6>
      <p class="card-text">{{}}</p>


Run Angular Application

In addition to to test the application, Consequently execute the following command to start the angular development server:

ng serve

Add the following url in the browser, and execute the below command:


Custom Filter Search Pipe in Angular


We have created a custom search pipe to filter results in Angular dynamically.

This step-by-step guide explained everything about creating a custom search filter pipe in the angular app using angular pipe and Bootstrap framework.