"track by" in simple comprehension expression broke when updating from 0.11.2 to 0.13.1
The expressions
<ui-select-choices
repeat="question in questions track by question.question_id"
group-by="'searchGroup'"
refresh="refreshQuestions($select.search)"
refresh-delay="250">
<div question-preview-item="question"></div>
</ui-select-choices>
used to work in 0.11.2, but after I upgraded to 0.13.1, I receive the following error:
Error: [$parse:syntax] Syntax Error: Token 'track' is an unexpected token at column 11 of the expression [questions track by question.question_id] starting at [track by question.question_id]
Changing the repeat value to repeat="question in questions" avoids the error message, but is probably taking a toll in reduced performance.
Same true to me. Adding a filter fixes the issue:
<ui-select-choices
repeat="question in questions | filter: $select.search track by question.question_id"
....
</ui-select-choices>
As much as I appreciate your workaround, @dangoodman, it doesn't fix the issue. :wink:
I really hope this issue will be properly fixed in the future, as adding a filter does not make much sense in my case where the list of questions is updated, and filtered, through an async (AJAX) server call.
Sure, it's just a workaround, not a real fix.
Happens to me also, but when updating from 0.13.1 to 0.13.2.
<ui-select-choices repeat="product in dropdownVM.productsForDropDown track by product.id"
refresh="dropdownVM.searchProducts($select.search)"
refresh-delay="0">
+1 Downgraded from 0.13.2 to 0.13.1 and it works.
@rgiosa, thank you!! Downgrading from 0.13.2 to 0.13.1 worked for me as well.
0.13.1 didn't work for me.
0.13.1 didn't work for me neither. Any solution?
I got this issue too and need to downgrade to 0.13.0 for it to work. It seem to be #1216 change in 0.13.1 that cause this regression.
The part that handle the filter block in the regexp for repeatFilter may be the cause. There is a | character that isn't escaped but we actually want to match the char, and this filter block should probably be optional also.
This issue also affects custom filters:
<ui-select-choices
repeat="result in results
| customFilter:$select.search
| orderBy: result.score track by: result.result
">
Throws the same error
A workaround I found from https://github.com/angular-ui/ui-select/issues/1270 was to wrap the collection in parens:
<ui-select-choices repeat="user in (ctrl.users) track by $index" ...>
@techniq +1
Thanks @jfairley, it worked for me as well. Just to note that I used the 0.14.9 version that is posted here: https://cdnjs.com/libraries/angular-ui-select
And I think that the version is not properly stated: Version: 0.14.8 - 2016-02-18T22:01:43.792Z Where it should read 0.14.9