如何在同一用户界面选择字段上同时应用filter:$ select.search和limitTo:$ select.infiniteCurrentLimit?

问题描述 投票:2回答:1

我有使用无限滚动功能的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>

我有什么办法可以让他们能够一起工作?

javascript angularjs infinite-scroll ui-select
1个回答
0
投票

经过大量的Google搜索,反复试验和错误发现后,找到了解决方案。我只是对app.bigListfilter进行了分组,以便将其作为已过滤的列表返回以供limitTo使用。像PEMDAS这样的作品。

repeat="option.id as option in (app.bigList | filter: { value: $select.search }) | limitTo: $select.infiniteCurrentLimit">
© www.soinside.com 2019 - 2024. All rights reserved.