UNPKG

vc-select-dropdown

Version:

A angular(4+) select dropdown for single select or multiselct module.

46 lines 1.66 kB
import { Pipe } from "@angular/core"; /** * filters an array based on searctext */ var ArrayFilterPipe = /** @class */ (function () { function ArrayFilterPipe() { } ArrayFilterPipe.prototype.transform = function (array, searchText, keyName) { if (!array || !searchText || !Array.isArray(array)) { return array; } if (typeof array[0] === 'string') { return array.filter(function (item) { return item.toLowerCase().indexOf(searchText.toLowerCase()) > -1; }); } // filter array, items which match and return true will be // kept, false will be filtered out if (!keyName) { return array.filter(function (item) { for (var key in item) { if (typeof item[key] !== "object" && item[key].toString().toLowerCase().indexOf(searchText.toLowerCase()) > -1) { return true; } } return false; }); } else { return array.filter(function (item) { if (typeof item[keyName] !== "object" && item[keyName].toString().toLowerCase().indexOf(searchText.toLowerCase()) > -1) { return true; } return false; }); } }; ArrayFilterPipe.decorators = [ { type: Pipe, args: [{ name: "filterBy" },] }, ]; /** @nocollapse */ ArrayFilterPipe.ctorParameters = function () { return []; }; return ArrayFilterPipe; }()); export { ArrayFilterPipe }; //# sourceMappingURL=filter-by.pipe.js.map