Cannot insert new value using angular ui typeahead

484 views Asked by At

Hi have a problem angular ui typeahead: I pratically copied this sample from the angular ui page, updated to the latest version of every library.

<input type="text" ng-model="vm.censimento.quartiere" placeholder="prima selezionare il comune"
       typeahead="address for address in vm.quartieri"
       typeahead-loading="loadingLocations" class="form-control" />
<i ng-show="loadingLocations" class="glyphicon glyphicon-refresh"></i>

In the angular page this sample is able to select items from the list AND add leave new text in the input when I exit from the textbox, but in my application add something, the first item is automatically selected and when I leave the textbox the value of the selected item override any text i wrote.
How can I avoid this? I need to choose from the list and add new item form the same control.

Luca

1

There are 1 answers

0
Luca Morelli On

finally I found the solution: to be able to insert text in the textbox I have to add
typeahead-focus-first="false":
the default value is true and select automatically the first item. I suppose that in the version of angular ui bootstrap where I took the sample the default value was the opposite.