Hello Sendar
This helps , also array has name and description, is it possible to search
in both rather just in one name ?

On Thursday, July 25, 2019, Sander Elias <sanderel...@gmail.com> wrote:

> Hi Dev,
>
> Your search pipe expects an object with at least the property name in each
> row, and your sort expects an array that contains only strings. Make sure
> you have those in sync.
> I changed them a bit, so they now accept a property's name:
>
> @Pipe({name: "sort"})
> export class ArraySortPipe implements PipeTransform {
> transform(array: Array<string>, propName: string): Array<string> {
> return [...array.sort((a: any, b: any) => a[propName] < b[propName] ? -1 :
> 1)]
> }
> }
>
> @Pipe({ name: 'search' })
> export class SearchPipe implements PipeTransform {
> transform(value: any[], prop,term: string): any[] {
> return value.filter((x: any) => term === '' || x && x[prop] && x[prop].
> toLowerCase().includes(term.toLowerCase()))
> }
> }
>
> See it in action on stackblitz
> <https://stackblitz.com/edit/angular-fu1hkj>
>
> Regards
> Sander
>
> --
> You received this message because you are subscribed to the Google Groups
> "Angular and AngularJS discussion" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to angular+unsubscr...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/angular/c90588ab-3375-4f70-b992-3ad2c5626874%40googlegroups.com
> <https://groups.google.com/d/msgid/angular/c90588ab-3375-4f70-b992-3ad2c5626874%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 
Sent from my mi note 4 phone.

-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to angular+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/angular/CAKVZMjCmH%2BTRv7vFux2pJ_CWNT1es_83KEJQgeehNXvHjzLDNQ%40mail.gmail.com.

Reply via email to