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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/angular/c90588ab-3375-4f70-b992-3ad2c5626874%40googlegroups.com.

Reply via email to