bootstrap icon indicating copy to clipboard operation
bootstrap copied to clipboard

Typeahead "select on exact" does not work when using an expression for "label" part

Open matthias-ccri opened this issue 9 years ago • 2 comments

Typeahead allows the format select as label for value in sourceArray. It is possible to have an expression for "label", like so: state.id as state.name + ' (' + state.id + ')' for state in states.

This works fine unless you use it with typeahead-select-on-exact. In that case, it never matches the full label expression; it breaks after the first part (at the "plus").

I figure that label expressions might just be "not supported" (yet), but I thought I'd document this issue here, for whoever else might be searching for it.

Plunker

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

Versions

Angular: 1.5.5 UIBS: 2.0.1 Bootstrap: 3.3.6

matthias-ccri avatar Aug 08 '16 16:08 matthias-ccri

That looks like a complex expression for the label - I think it would be easier to instead use a custom template since the matches array is exposed to the typeahead popup.

If you would like to take a stab at it, I believe the main part that would need modifying is https://github.com/angular-ui/bootstrap/blob/0023d1bd9767921581498feaffb8729a927fce9e/src/typeahead/typeahead.js#L214 .

wesleycho avatar Aug 09 '16 08:08 wesleycho

How to resolve this problem?

lemonl2 avatar Nov 22 '17 10:11 lemonl2