gpt4 book ai didi

javascript - 如何在同一 ui-select 字段上同时应用过滤器 :$select. 搜索和 limitTo :$select. infiniteCurrentLimit?

转载 作者:行者123 更新时间:2023-11-30 06:12:01 26 4
gpt4 key购买 nike

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

所以我决定在其上实现 filter: $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>

有什么我可以做的让他们能够一起工作吗?

最佳答案

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

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

关于javascript - 如何在同一 ui-select 字段上同时应用过滤器 :$select. 搜索和 limitTo :$select. infiniteCurrentLimit?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58333710/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com