import {Pipe, PipeTransform} from '@angular/core'
@Pipe({
name: "sort"
})
export class ArraySortPipe implements PipeTransform {
transform(array: Array<string>, args: string): Array<string> {
array.sort((a: any, b: any) => {
console.log("22")
if (a < b) {
console.log("!")
return -1;
} else if (a > b) {
console.log("2")
return 1;
} else {
console.log("3")
return 0;
}
});
return array;
}
}
and below is the code for search pipe
import {Pipe, PipeTransform} from '@angular/core';
@Pipe({name: 'search'})
export class SearchPipe implements PipeTransform {
transform(value: any[], term: string): any[] {
return value.filter((x: any) => x.name.toLowerCase().startsWith(term.toLowerCase()))
}
}