I am using a filter on an array of items in a ng-repeat like this:
<input type="text" ng-model="filterText">
<li ng-repeat="item in displayItems | filter : {item_name: filterText}>
This works fine and filters the items perfectly.The problem arises because I am using displayItems with a uib-pagination element. The pagination uses totalItems instead of displayItems.
<uib-pagination class="pagination-sm pagination"
total-items="totalItems.length" ng-model="page" ng-change="changeItems()">
</uib-pagination>
Obviously I need to somehow apply the filter on the total-items, then create the displayItems, and put the filteredItems in the uib-pagination.
Ie. When the person types, in the controller the filter is applied to the totalItems, and I create the filteredItems needed for the pagination. I also then create the displayItems from the filteredItems. How do I go about putting this into the controller and not in the HTML for the ng-repeat?
I'm not sure how to do this. Any thoughts? All help much appreciated....
I've included a plunker to show it (not) working in all its glory.... https://plnkr.co/edit/EYX6zO1795sD9TYq2J8U?p=preview