我有使用无限滚动功能的ui-select字段,因为它可能有很多选项,但是由于有很多选择,向下滚动以查找所需的选项很累人。
<ui-select-choices
infinite-scroll="$select.infiniteStepIncrement()"
infinite-scroll-distance="2"
infinite-step="2"
current-limit="10"
all-options="app.bigList"
repeat="option.id as option in app.bigList | limitTo: $select.infiniteCurrentLimit">
<span ng-bind-html="option.value"></span>
</ui-select-choices>
因此,我决定实施过滤器:$ select:search。它过滤选项,但取消可滚动功能。
<ui-select-choices
infinite-scroll="$select.infiniteStepIncrement()"
infinite-scroll-distance="2"
infinite-step="2"
current-limit="10"
all-options="app.bigList"
repeat="option.id as option in app.bigList | filter: $select.search | limitTo: $select.infiniteCurrentLimit">
<span ng-bind-html="option.value"></span>
</ui-select-choices>
我有什么办法可以让他们能够一起工作?
经过大量的Google搜索,反复试验和错误发现后,找到了解决方案。我只是对app.bigList
和filter
进行了分组,以便将其作为已过滤的列表返回以供limitTo
使用。像PEMDAS这样的作品。
repeat="option.id as option in (app.bigList | filter: { value: $select.search }) | limitTo: $select.infiniteCurrentLimit">