-
Notifications
You must be signed in to change notification settings - Fork 3.4k
md-autocomplete clear text entry when item is selected #1829
Comments
What do you mean by cleared? |
I'm pretty certain @kschwidder is talking about adding an option that allows for the text field to be cleared once a selection is made from the autocomplete dropdown. This is useful when using the same autocomplete field to make multiple selections. |
indeed ! |
@kschwidder Wouldn't this be accomplished by binding something to the searchText and clearing that value on select? |
It doesn't since after a selection the option is shown with a clearance button. When setting the SearchText the button is still shown. There is currently no way to close the button via an API. |
Have same issue. I solve it like that : $scope.selectedItemChange= function(){
// some stuff with selectedItem
// clear input
$scope.searchText = '';
$scope.selectedItem= undefined;
};
|
Is this what you are trying to do? http://codepen.io/robertmesserle/pen/72185ea178757d282e5862fcc22399dd?editors=101 |
yes |
The difference in my case is that the md-items="item in loadData(md.searchText)" is a $http request. |
Ah, there is already an issue for that: #1798 I'm going to look into a fix for that right now. |
do it: |
and my js file for the button here Question... how can i make the same button to reset to default the selected option in autocomplete? |
+1 There are thousands of use cases where this is intended. Ex: |
+1 This workaround fixed
but the list with the options keeps opened :( |
To clear the text, use the workaround suggested. However, with default options, the list will remain open since the search field has the focus. To close the list, ensure that the |
This work for me!!! # |
It would be beneficial if the md-autocomplete can be customized to clear the text when an item has been selected. When using the md-autocomplete to search for items and maintaining a list of objects it is cumbersome to always press the clear button.
As a workaround I am accessing the $mdAutocompleteCtrl and triggering the clear() method but this is not a good decision....
The text was updated successfully, but these errors were encountered: