I\'ve written a construct similar to the following in an Angular app (this has been greatly simplified to demonstrate the issue). What would prevent the filte
As I think filter
is reserved keyword. So that angular trying to implement filter
function on type Object
. filter
can be used only for Array
. try using different name for the function.
If this is not the case. Maybe the service data item should come as Object
instead of TTem
instance.We can get the class methods only on its instances. Can you try creating new instance as follows
this.filteredData = this.service.data.value.slice().filter(
(item: TItem) => {
// Object doesn't support property or method 'filter'
let instance: TItem = new TItem();
Object.assign(instance, item);
const searchStr = instance.filter().toLowerCase();
return searchStr.indexOf(this.filter.toLowerCase()) !==-1;
});