Saurabh Verma Saurabh Verma - 4 months ago 42
AngularJS Question

AngularMaterial md-chips : Dont show selected item in <md-autocomplete>

I'm trying the

<md-autocomplete>
example from here md-chips

To prevent the selected items from coming inside
<md-autocomplete>
I've modified the querySearch function like this:

function querySearch (query) {
var results = query ? self.searchData.filter(createFilterFor(query)) : [];
var finalResults = [];
angular.forEach(results, function(result) {
if($scope.selectedItems.indexOf(result.name) < 0) {
finalResults.push(result);
updateSelectedItems(result);
}
});
return finalResults;
}


But my problem is that the control does not come inside this function once we select an item. Can someone please explain how to solve this ?

Answer

I found the solution from this documentation: md-autocomplete

We just need to add md-no-cache="true" for calling the querySearchfunction each time we search for a query item