I am working with an array that includes three properties:
ID : number
Name : string
Description :string
ItemList :array<T>=[] and
ItemListCopy :array<T>=[]
Currently, this array is linked to the ng-multiselect
dropdown
During the onFilterChange
callback, I am passing the search text to this method and attempting to locate all items in ItemListCopy
where the Name
includes the search text.
I have tried the following approach:
var v = this.ItemListCopy.filter(item =>
Object.keys(item).some(k => item[k].includes(text))
)
if (v != null && v.length > 0) {
this.ItemList.length = 0;
this.ItemList= v;
}
Here, the parameter containing the search text is represented as 'text'.
However, I encountered an error stating that item[k].includes(text)
is not a method.
Is there a way to successfully achieve this task?