forked from CuppaLabs/angular2-multiselect-dropdown
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlist-filter.js
More file actions
45 lines (45 loc) · 1.48 KB
/
list-filter.js
File metadata and controls
45 lines (45 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { Pipe } from '@angular/core';
var ListFilterPipe = (function () {
function ListFilterPipe() {
}
ListFilterPipe.prototype.transform = function (items, filter, searchBy) {
var _this = this;
if (!items || !filter) {
return items;
}
return items.filter(function (item) { return _this.applyFilter(item, filter, searchBy); });
};
ListFilterPipe.prototype.applyFilter = function (item, filter, searchBy) {
var found = false;
if (searchBy.length > 0) {
for (var t = 0; t < searchBy.length; t++) {
if (filter && item[searchBy[t]] && item[searchBy[t]] != "") {
if (item[searchBy[t]].toString().toLowerCase().indexOf(filter.toLowerCase()) >= 0) {
found = true;
}
}
}
}
else {
for (var prop in item) {
if (filter && item[prop]) {
if (item[prop].toString().toLowerCase().indexOf(filter.toLowerCase()) >= 0) {
found = true;
}
}
}
}
return found;
};
return ListFilterPipe;
}());
export { ListFilterPipe };
ListFilterPipe.decorators = [
{ type: Pipe, args: [{
name: 'listFilter',
pure: false
},] },
];
/** @nocollapse */
ListFilterPipe.ctorParameters = function () { return []; };
//# sourceMappingURL=list-filter.js.map