I have recently included a new filter for DL, but it seems that the results are not showing up as expected. Any ideas on what changes I should implement?
<div class="form-group float-left mr-4">
<strong>DL</strong>
<br />
<select class="form-control form-control-sm" name="dl" ngModel [ngModelOptions]="{updateOn: 'submit'}">
<option></option>
<option value="CAT1">CAT1</option>
<option value="CAT2">CAT2</option>
</select>
</div>
table-filter.pipe.ts
import { Pipe, PipeTransform } from "@angular/core";
@Pipe({
name: "tableFilter"
})
export class TableFilterPipe implements PipeTransform {
transform(list: any[], filters: any) {
const keys = Object.keys(filters).filter(key => filters[key]);
const filterUser = (user: { [x: string]: any; }) =>
keys.every(key => {
if (key == "sdob") {
return new Date(user["dob"]) >= new Date(new Date(filters[key]).setHours(0,0,0,0));
} else if (key == "edob") {
return new Date(new Date(filters[key]).setHours(0,0,0,0)) >= new Date(user["dob"]);
} else {
return user[key] === filters[key];
}
});
return keys.length ? list.filter(filterUser) : list;
}
}
URL: https://stackblitz.com/edit/angular-ivy-dubf37?file=src%2Fapp%2Fapp.component.html