Thursday, 22 November 2018

FilterPipe in angular (compair test)




import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
name: 'filter'
})
export class FilterPipe implements PipeTransform {

// Strategies| filter: {q: searchText,find: 'Cloumn Name' }
transform(value: any, args?: any): any {
// console.log({ 'Pipe Value:': value });
// console.log({ 'Pipe OP:': args });
let id = args.q; //Find Value
let q = args.find; //Find Column
// let r = args.res; //Result Column
let res: any[] = [];
if (id == undefined || id == '') {
return value;
}

if (value != undefined) {
value.find(x => {
// console.log("X>>",x);
// console.log("Compare:", "Find:"+q+"=" + id + "
//Current:"+q+"="+x[q]+ " -> Result: "+r+"="+x[r]);
if (x[q].toLowerCase() === id.toLowerCase()) {
res.push(x);
}
});
// console.log({ 'Pipe res:': res });
return res;
}

}
}

No comments:

Post a Comment

IIS deployment support details

  Node JS - IIS deployment support details node: http://go.microsoft.com/?linkid=9784334 IISNode: https://github.com/azure/iisnode/releases/...