-
Notifications
You must be signed in to change notification settings - Fork 3.4k
md-autocomplete pre-selected value #1779
Comments
+1 |
3 similar comments
+1 |
+1 |
+1 |
A quick review of the controller source reveals a watcher on searchText $scope.$watch('searchText', wait
? $mdUtil.debounce(handleSearchText, wait)
: handleSearchText);
} This allows us to set the search text in our controller while loading the state. //Populate the searchText property on the object bound to the md-search-text attribute in md-autocomplete
vm.autoComplete.searchText = preSelectedText; And just like that, you can set a pre-selected value; |
Whilst that is correct to set the text-field to the selected text, it does perform the same function as selecting an item from the list. Specifically it still leaves the selection box open. |
It shouldn't if there is only one result. It is working perfectly for me. |
See this codepen: |
What if you wanted to tab and then pre-fill the autocomplete with a specific value? Would you want to populate the searchText property on the object bound to the md-search-text attribute in md-autocomplete or the selectedItem property? |
doing an ng-init for the preselected value works for me.
|
I do not understand this as a solution, it seems no different to On 12 March 2015 at 14:28, Jethro Guce notifications@github.com wrote:
|
like @ACDN, mine has only single result. I don't get it why it won't work on yours, even if I have removed the 'Alabama2', it the drop box is still open. |
👍 |
this works for me, but only if i then manually click on the field after page load does the selectedItemChange fire and the preset fills. any ideas on how to trigger it without the click? |
I want to pre-fill the autocomplete value (use cases = editing an existing value or retaining state on refresh). However, simply changing the model to the pre-selected item does not work as it leaves the dropdown of options visible even if the autocomplete is not in focus. Is there a way to disable the dropdown if a valid entry is already selected and the input is not focused?
The text was updated successfully, but these errors were encountered: