I am creating a simple customer management app. One of the functionalities is to filter through the table to list active and inactive customers. My issue is when clicked on the dropdown I can't get the boolean value, that is true/false, but only strings "true"/"false" hence my filter will not work.
Here is my html:
<strong class="ml-2">Active Status</strong>
<select class="ml-1" name="activeStatus" [(ngModel)]="activeStatus">
<option></option>
<option value=true>Active</option>
<option value=false>Not Active</option>
</select>
My table filter pipe:
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'tableFilters'
})
export class TableFiltersPipe implements PipeTransform {
transform(list: any[], filters: Object) {
const keys = Object.keys(filters).filter(key => filters[key]);
const filterUser = user => keys.every(key => user[key] === filters[key]);
return keys.length ? list.filter(filterUser) : list;
}
}
[value]="true"- Sumeet Kale[ngValue]:<option [ngValue]="true">. - ConnorsFan