i have a collection of devices with the following structure:
export interface Device {
id: Number;
tracker_status?: Trackerstatus;
}
export interface Trackerstatus {
last_update?: Date;
battery_low?: any;
}
when applying a filter like this:
function filterDevices(device: any) {
if (device.id == 5){
return true;
}else{
return false;
}
}
everything works as expected.
now, my intention is to use a different filter that looks like this:
function filterDevices(device: any) {
if (device.tracker_status.battery_low == "true"){
return true;
}else{
return false;
}
}
however, when using this new filter, I end up getting an empty list without any error messages. What could be the issue?
my ultimate goal is to display the filtered data in an Angular table. This is how I am currently using the filter:
devices: Device[] = data.filter(filterDevices);