簡體   English   中英

AngularJS使用limitTo和ngrepeat中的過濾器進行混淆

[英]AngularJS conflit with limitTo and filter in ngrepeat

我有很多關鍵字ng-repeat (> 100 000),這就是我使用limitTo:的原因limitTo:但我希望能夠在ALL中搜索。

Search: <input ng-model="filter:queryKeywords" type="text" placeholder="Filter" autofocus>

<label ng-repeat="k in keywords | limitTo:totalDisplayed | orderBy | filter:queryKeywords">
   {{k}}
</label> 

<!-- Will load 100+ keywords -->
<button class="btn btn-primary" ng-click="seeMore()">See More</button>

問題是我的搜索僅適用於我能看到的項目。

我想搜索所有項目(甚至是我無法顯示的項目)。

謝謝!

您應該更改過濾器的順序,以便首先進行搜索(因此適用於所有數據),然后進行限制/排序:

ng-repeat="k in keywords | 
           filter:queryKeywords |
           limitTo:totalDisplayed |
           orderBy"

Angular按順序應用過濾器。 更改過濾器的順序應該可以解決您的問題。

<label ng-repeat="k in keywords | filter:queryKeywords | limitTo:totalDisplayed | orderBy">

這意味着:首先過濾,然后將結果限制為totalDisplayed並最終對其進行排序。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM