Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.

Angular 2 / Angular 4 / Angular 5 custom pipe npm module to make a search filter on any input, 🔥 1Million+ downloads

License

Notifications You must be signed in to change notification settings

solodynamo/ng2-search-filter

Repository files navigation

Angular 2 / Angular 4 / Angular 5 Search Filter Pipe

npm version

Filter search items

Angular 2 filter to make custom search. Works with Angular 4 and Angular 5 too.

demo-image

Install

npm i ng2-search-filter --save
yarn add ng2-search-filter 

Usage

In case you're using systemjs - see configuration here.

Import Ng2SearchPipeModule to your module

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

import { Ng2SearchPipeModule } from 'ng2-search-filter';

@NgModule({
  imports: [BrowserModule, Ng2SearchPipeModule],
  declarations: [AppComponent],
  bootstrap: [AppComponent]
})
export class AppModule {}

And use pipe in your component after declaring and initializing it in your component:

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

@Component({
  selector: 'example-app',
  template: `
    <div>
        <input type="text" [(ngModel)]="term">
        <div *ngFor = "let item of items |filter:term" >
          <p>
            {{item.name}}
          </p>
        </div>

    </div>  
  `
})

export class AppComponent {
  items: string[] = [{ name: "archie" }, { name: "jake" }, { name: "richard" }];
  term = '';
}

Support ng2-search-filter

ng2-search-filter is completely free and open-source. If you find it useful, you can show your support by 🌟 it or sharing it in your social network.

Contribute

Please do 🙂

License

MIT © Solodynamo