In my .ts file, I have the following code snippet:
search(event) {
this.autocompletedata.filter((entry) => {
console.log('entryyyy',entry);
if (this.showFilter == 1) {
this.results = entry['items'].filter( a => a['item'] ? a['item'].startsWith(event.query) : false);
}
else if (this.showFilter == 2) {
this.results = entry['items'].filter( a => a['service'] ? a['service'].startsWith(event.query) : false);
}
else if (this.showFilter == 3){
this.results = entry['items'].filter( a => a['phoneNum'] ? a['phoneNum'].startsWith(event.query) : false);
}
});
}
The issue I'm facing is that I am receiving duplicated data. Any suggestions on how to remove duplicates from the array?
Below is my full autocomplete code.
This is the structure of the items:
https://i.sstatic.net/boLP1.png
In the last 'if' statement, the results are displayed as suggestions. However, since the array contains multiple instances of the same number, I see repeated suggestions which I want to eliminate. I only want one instance to be displayed.