Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

opening ngx-bootstrap typeahead on focus

Is there any way to open the ngx-typeahead when a user enters the input. In other words, on focus

enter image description here

I can get the dropdown to open if I type a single character into the input box, and then hit backspace.

enter image description here

like image 218
Jim Avatar asked Oct 20 '25 13:10

Jim


2 Answers

just add this to the input

[typeaheadMinLength]="0"
like image 138
Hamzah Murrar Avatar answered Oct 23 '25 02:10

Hamzah Murrar


Setting [typeaheadMinLength]="0" is the way to do this, but it also has the side effect of triggering a search even when nothing is typed in yet. I my case I needed to run the search on focus, but only if the textbox already had some content. I did this using a reference to the input's value:

<input #searchBox
[typeaheadMinLength]="searchBox.value?.length > 0 ? 0 : 1"
/>
like image 39
Caleb Bertrand Avatar answered Oct 23 '25 02:10

Caleb Bertrand