# Filter

We have created a filter pipe to make the filter functionality easy to implement. Lets have a look on it.

# Requirements


You can import CorePipesModule directly or import our CoreCommonModule which has all the required modules.

To use filter pipe, we need to import the CorePipesModule to that specific module where we want filter functionality.

import { CorePipesModule } from '@core/pipes/pipes.module';
declarations: [
imports: [
providers: []

# Usage

Use pipe filter with *ngFor structural directive to implement filter functionality.

Example :

  placeholder="Ask a question..."

  *ngFor="let knowledgeBaseRef of data.knowledgeBase | filter: searchText:'title'"
  class="col-md-4 col-sm-6 col-12 kb-search-content"
  <div class="card">
    <a routerLink="/pages/knowledge-base/{{ knowledgeBaseRef.category }}">
      <img src="{{ knowledgeBaseRef.img }}" class="card-img-top" alt="knowledge-base-image" />
      <div class="card-body text-center">
        <h4>{{ knowledgeBaseRef.title }}</h4>
        <p class="text-body mt-1 mb-0">{{ knowledgeBaseRef.desc }}</p>

Here searchText is a variable where we get the updated input text. 'title' is what we are filtering.

You can check demo in navbar on this (opens new window) page.

Last Updated: 3/9/2021, 1:15:52 PM