-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Typeahead does not support "group by" or "track by" syntax #506
Comments
@bowsersenior while the syntax used in typeahead is heavily inspired by the one used in the When I was writing the initial version of the typeahead I've left over For the |
Thanks for the clarification. I think it is worth implementing the exact same syntax as The use case for "group by" is when you want to organize results. Imagine you have an input field where you can type in a username and you want the typeahead list to group the users by their role ("Admin", "Customer Service", etc.). I think consistency is a more important concern, though. Introducing a syntax that is close to that for In the meanwhile, I think a necessary first step is to clarify the documentation for typeahead to clarify the syntax. Right now,the documentation for typeahead states: And the only info on the typeahead syntax is a link to the |
@bowsersenior thnx for getting back to me on this one. Yes, totally agree, docs need to be clarified. What I was asking more directly is if you got an immediate use-case that needs attention. I understand that grouping would be nice to add and I can imagine use-cases for this. At the same time there are other parts where I think time be better invested, custom templates for matched items being one example. But I will let people vote here :-) |
@pkozlowski-opensource I understand your point of view. Actually, I personally don't have a use case right now for this. |
i have a use case for this. my search is a multi-search. it could be over contacts, companies, etc. i want to group the results by type (and would like headers on those sections). i'm actually considering angular typeahead for our rewrite of our search widget but it would be hard to justify if i can't do this. |
@scamden Great that you have a use case for this one! Personally I don't need this functionality at the moment so a pull request (with tests) would be the fastest way of getting this functionality in the project! |
@bowsersenior @scamden we are preparing for a bigger overhaul of this project and as indicated already this is not a top priority for me. Feel free to open a PR with test if you need this one and have an idea of implementation. Thnx! |
ok thanks! i'll get on that as soon as we rewrite the uses of the search widget that need the group by. actually if you could point me at some good resources to get better at testing @pkozlowski-opensource that would really help. we're just beginning to convert our old gwt app to angular and we want to make testing a priority. we have a few tests, but looking briefly at the tests for this project it's clear to me that we could improve. thoughts? |
Trim the trailing space left by a new tag's label.
It seems that the regex used to parse the
typeahead
expression has gotten out of sync with the syntax available in theselect
directive. I can see that keeping these in sync could be an ongoing challenge as there doesn't seem to be an easy way to extract the regex and parser fromselect
. Perhaps the correct long-term fix is for AngularJS to extract the parser forselect
into a reusable service and have typeahead use that directly.In the short-term, perhaps the typeahead regex and parser can be updated to at least add support for the "group by" syntax, which can be useful, I think. In general, I think it is a great idea to re-use the exact same syntax as
select
.Here are the details. The
select
directive'sng-options
attribute allows a "group by" clause:(from: http://docs.angularjs.org/api/ng.directive:select)
However, it seems that typeahead does not parse for the "group by" syntax:
Also, recently a "track by" syntax was added:
The relevant lines in the current AngularJS source where the regex is defined:
... and where the syntax is parsed using the regex above:
The text was updated successfully, but these errors were encountered: