How to Build List Filtering and Searching in Ionic 7

Last Updated on by in Ionic

This tutorial explains how to create a search filter in Ionic Angular application, and we can search and filter data list using the Ionic search filter.

Showing a data or records list is a usual practice for web developers.

In this tutorial, we will see how to implement the search and list filtering feature in an Ionic mobile application.

Also, we will build an Ionic app on the Angular platform to amplify the Ionic search performance.

In the previous tutorial, we talked about creating a search filter in Angular. You must check out this tutorial if you are an Angular lover.

To smoothen our work, we are using a third-party plugin ng2-search-filter.

This plugin comes with robust features and offers a filter pipe which can be associated with Angular’s *ngFor directive to add the search filter functionality.

Create Ionic Application

Before we begin make sure you have Ionic CLI installed.

sudo npm install -g @ionic/cli

So, open your command prompt and execute the following command:

Next, install a new Ionic Angular application:

ionic start ionic-search-filter-example blank --type=angular

Navigate to project root:

cd ionic-search-filter-example

Run the below command to add the native core package.

npm install @ionic-native/core --legacy-peer-deps

Disable Strict Type Errors

To avoid TypeScript compiling issues, we just need to open tsconfig.json file:

First, set below property under “compilerOptions” property.

"compilerOptions": {
    "strictPropertyInitialization": false,
    "skipLibCheck": true

Secondly, add given props under “angularCompilerOptions”.

"angularCompilerOptions": {
    "strictTemplates": false,

Install ng2-search-filter Plugin in Ionic

Navigate to your terminal or command prompt and execute the following command to install the ng2-search-filter library:

npm i ng2-search-filter@0.4.7 --legacy-peer-deps

Add Ng2SearchPipeModule Module

We need to register the Ng2SearchPipeModule in Ionic; we are using the default Home page to create a search filter; however, you can create your own page.

Head over to home.module.ts file and import the Ng2SearchPipeModule from ‘ng2-search-filter’, Also inject the search module in imports array.

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { IonicModule } from '@ionic/angular';
import { FormsModule } from '@angular/forms';
import { HomePage } from './';

import { HomePageRoutingModule } from './home-routing.module';
import { Ng2SearchPipeModule } from 'ng2-search-filter';

  imports: [
  declarations: [HomePage],

export class HomePageModule {}

Create List with Searching and Filtering

Next, we will move to the essential step here, and we will build a list. And also, add the searching and filtering functionality in it.

We need to define some random dummy data, we will search and filter this data object.

Add the following code in file:

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

  selector: 'app-home',
  templateUrl: '',
  styleUrls: [''],

export class HomePage {
  filterTerm: string;

  constructor() { }

  userRecords = [{
      "id": 1,
      "name": "Leanne Graham",
      "email": ""
      "id": 2,
      "name": "Ervin Howell",
      "email": ""
      "id": 3,
      "name": "Clementine Bauch",
      "email": ""
      "id": 4,
      "name": "Patricia Lebsack",
      "email": ""
      "id": 5,
      "name": "Chelsey Dietrich",
      "email": ""
      "id": 6,
      "name": "Mrs. Dennis Schulist",
      "email": ""
      "id": 7,
      "name": "Kurtis Weissnat",
      "email": ""
      "id": 8,
      "name": "Nicholas Runolfsdottir V",
      "email": ""
      "id": 9,
      "name": "Glenna Reichert",
      "email": ""
      "id": 10,
      "name": "Clementina DuBuque",
      "email": ""


Let us create a Ionic template with search bar, So place the given below code in file:


<ion-header [translucent]="true">
      Ionic Search Filter Demo

<ion-content [fullscreen]="true">
  <ion-searchbar placeholder="Search..." [(ngModel)]="filterTerm" animated="true"></ion-searchbar>

    <ion-item *ngFor="let data of userRecords | filter:filterTerm">

Run Ionic Application

To start the application in the browser, kindly execute the following command from command prompt:

ionic serve --lab

Here is the final output:

How to Build List Filtering and Searching in Ionic

The Bottom Line

Finally, we have seen the nitty-gritty that are very important to thrive your knowledge to build list filtering and searching in Ionic application.

I assume you will like this tutorial and share it with others too.

Digamber - Author

Hi, I'm Digamber Singh, a New Delhi-based full-stack developer, tech author, and open-source contributor with 10+ years' experience in HTML, CSS, JavaScript, PHP, and WordPress.