angular-strap icon indicating copy to clipboard operation
angular-strap copied to clipboard

typeahead-editable="false"

Open spj opened this issue 12 years ago • 8 comments

does angular-strap typeahead has a similar feature as typeahead-editable="false" does in angular-ui boostrap typeahead?

if no, how to implement one?

thanks,

spj avatar Aug 18 '14 15:08 spj

+1 for this one too. If not preventing invalid input (not matched) at least to invalidate it. With support for asynchronous matching of course...

ruifortes avatar Sep 10 '14 13:09 ruifortes

Isn't that sort of like the "selectMode" option? It prevents the user from inputing further if there is no match, but I see that it is not referenced in the docs and doesn't have tests for it. Maybe you can give it a try and see how it works.

vmlf01 avatar Oct 24 '14 17:10 vmlf01

selectMode=true does part of the job but it does not invalidate the input.

Adapted from the plunker in the docs: http://plnkr.co/edit/zYL1z5eeMirO2MBsIFqx?p=preview

georgebarbarosie avatar Apr 20 '15 13:04 georgebarbarosie

I've updated the example from the previous plunker with a modified typeahead directive that implements the correct (IMHO) behaviour for selectMode=true:

http://plnkr.co/edit/zPxHvtmfvGeSD6GG3EaK?p=preview

The changes in the direcive:

  • setting the view value to delete last character when selectMode=true and no options available applied with scope.$applyAsync() to prevent infinite digest loop
  • expose $typeahead.getActiveIndex() to be used in bsTypeAhead
  • if selectMode=true bind a function on element blur to either select the active option or set the view model to empty if no option is active

georgebarbarosie avatar Apr 22 '15 20:04 georgebarbarosie

Angular UI typeahead with typeahead-editable="false" does not prevent user from typing. It can only invalidate the model and set it to undefined. See the PR I've submitted to update the description there:

https://github.com/angular-ui/bootstrap/pull/3572/files#diff-0b60ff012eac4dea7d219af42bc78977L27 in https://github.com/angular-ui/bootstrap/pull/3572

dmitriz avatar Apr 25 '15 06:04 dmitriz

+1

jukkasi avatar Jul 22 '15 08:07 jukkasi

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jan 26 '19 05:01 stale[bot]

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

lock[bot] avatar May 05 '19 20:05 lock[bot]