2015-07-01 17 views
0

我有一個名爲ListA的列表。我正在執行一些過濾器並保存在一個名爲filteredList的新陣列中。在使用ng-repeat應用另一個過濾器之前保留過濾列表

<div ng-repeat="element in filteredList =(ListA| filter: {label:searchCategory.value} |filter:searchString)"> 

現在,我想用filteredList來實現分頁。我已經使用splice(start, end)實施了另一個頁面的分頁,其中我更新了startend值以更新可見陣列。 將拼接添加到過濾器將改變我的filteredList大小,我需要它來計算分頁的頁數。

我需要進入ng-repeat會是這樣的

ng-repeat="element in newList.splice(start, end)" where `newList` without splice is essentially `filteredList`. 

回答

1

在這種情況下,你需要在自己的Javascript來過濾列表。

您的方案

在你的控制器:

var ListA = [<some-data>]; 

$scope.filteredList = $filter('filter')(ListA, searchString); 
$scope.filteredList = $filter('filter')($scope.filteredList, {label:searchCategory.value}); 

你應該對某些事件的點擊使用Filter值,並重新計算在處理這個filteredList。

如果項目少於200,則可以通過在過濾器表達式上實現觀察器來實現實時過濾。

+0

完美!我把它放在一個函數中,並呼籲模型更改。雖然稍有變化。我已經更新了答案。謝謝! – Swanidhi

相關問題