From f8bc553eea87191edf2637070c667696dbb60ad0 Mon Sep 17 00:00:00 2001 From: Swapnali Shadanan Pode Date: Tue, 19 Feb 2019 18:56:25 +0530 Subject: Search pipe Adding search pipe Change-Id: I59253eadad17d914e06b5b66d7f01d8c6584388b Issue-ID: CCSDK-804 Signed-off-by: sp00501638 --- cds-ui/client/src/app/common/shared/pipes/search.pipe.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 cds-ui/client/src/app/common/shared/pipes/search.pipe.ts (limited to 'cds-ui/client/src/app/common') diff --git a/cds-ui/client/src/app/common/shared/pipes/search.pipe.ts b/cds-ui/client/src/app/common/shared/pipes/search.pipe.ts new file mode 100644 index 000000000..58b0dc264 --- /dev/null +++ b/cds-ui/client/src/app/common/shared/pipes/search.pipe.ts @@ -0,0 +1,15 @@ +import { Pipe, PipeTransform } from '@angular/core'; + +@Pipe({ + name: 'search' +}) +export class SearchPipe implements PipeTransform{ + transform(items: any[], searchText: string): any[] { + if(!items) return []; + if(!searchText) return items; +searchText = searchText.toLowerCase(); +return items.filter( it => { + return it.toLowerCase().includes(searchText); + }); + } +} \ No newline at end of file -- cgit 1.2.3-korg