I was trying to filter options based on search text in angular.This is the code I am getting value when I search a I get all elements containing a but if I type abc then I shouldn't get the whole array I should get only abc.
filterChanged(filterText: any) {
const ddd = filterText.target.value
const test= this.objFlatNodeParrentTempGroup;
const filtered = test.filter((chat) => {
const searchValue = ddd.toLowerCase();
return chat.children!.filter((user) => user.item?.toLowerCase().includes(searchValue)).length > 0 ;
});
this.dataSource.data = filtered;
this.treeControl.expandAll();
}
}