From 7022f766a714d3d9be4626bc5779b0eb733d87c6 Mon Sep 17 00:00:00 2001 From: trochas Date: Mon, 21 Oct 2024 16:38:32 +0200 Subject: [PATCH] update --- src/app/filter-pokemon--pipe.pipe.ts | 13 +++++++++++-- src/app/my-component/my-component.component.html | 8 ++++++-- src/app/my-component/my-component.component.ts | 1 + 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/app/filter-pokemon--pipe.pipe.ts b/src/app/filter-pokemon--pipe.pipe.ts index 3d977ae..533fc2c 100644 --- a/src/app/filter-pokemon--pipe.pipe.ts +++ b/src/app/filter-pokemon--pipe.pipe.ts @@ -5,8 +5,17 @@ import { Pipe, PipeTransform } from '@angular/core'; }) export class FilterPokemonPipePipe implements PipeTransform { - transform(value: unknown, ...args: unknown[]): unknown { - return null; + transform(pokes: any[], property?: string, searchString?: string): any { + if(typeof searchString == 'undefined'){ + return pokes; + } + else if (typeof pokes !== 'undefined' && typeof property !== 'undefined') { + return pokes.filter((poke) => { + return poke[property].toLowerCase().indexOf(searchString.toLowerCase()) !== -1; + }); + } else { + return []; + } } } diff --git a/src/app/my-component/my-component.component.html b/src/app/my-component/my-component.component.html index 7f99002..65e5f8d 100644 --- a/src/app/my-component/my-component.component.html +++ b/src/app/my-component/my-component.component.html @@ -4,10 +4,14 @@
id : {{id}} - +
+ +