如何在同一个 ui-select 字段上同时应用 filter:$select.search 和 limitTo:$se



我有使用无限滚动功能的 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:搜索。它会过滤选项,但会取消可滚动功能。

<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>

我能做些什么让他们能够一起工作吗?

经过大量的谷歌搜索和反复试验后找到了解决方案。 我只是对app.bigListfilter进行分组,以便它将作为已过滤的列表返回,供limitTo处理。有点像PEMDAS的作品。

repeat="option.id as option in (app.bigList | filter: { value: $select.search }) | limitTo: $select.infiniteCurrentLimit">

最新更新