1

I am doing searching on a page using angularjs and client side pagination .The problem is searching is implemented on particular page but not on full data.suppose there are 150 records and each page has 50 records ,the searching is done on that particlar page having only 50 records.i want data to be search on 150 records.Plz somebody help. here is my code

<tr ng-repeat="application in applications | filter:search | orderBy:orderByField:reverseSort">
3
  • Might want to check out ngTable, which supports filtering and pagination. Even if you don't use it, you could look through the source for inspiration. Commented Dec 11, 2015 at 3:55
  • 1
    The line of code you posted is just a repeat of all rows. How are you splitting them into pages? Commented Dec 11, 2015 at 3:58
  • if the data is completely on client side and pagination is done on client side we can use, filter '$filter('filter')($scope.applications, searchTerms);' irrespective of any page. Commented Dec 11, 2015 at 4:09

1 Answer 1

1

have data completely on client side: in the object

in my case it is customers object:

$scope.customers = function () {
        return [
            {name: 'customer1'},
            {name: 'customer2'},
            {name: 'customer3'},
            {name: 'customer4'},
            {name: 'customer5'},
            {name: 'customer6'}
        ];
    };

    console.log(customers);

    $scope.currentPageCustomers = $scope.customers;

    $scope.search = function (searchTerm) {
            $scope.currentPageCustomers = $filter('filter')($scope.customers, searchTerms);
        };

Paginate:

$scope.paginateCustomers = function (page, customers) {
            var end, start;
            start = (page - 1) * 10;
            end = start + 10;
            return $scope.currentPageCustomers = customers.slice(start, end);

        };

html:

 <input ng-model='val' data-ng-keyup="search(val)" placeholder="Enter serch text"/>


<div data-ng-repeat="customer in currentPageCustomers">
  <ul>
    <li>{{customer.name}}</li>
 </ul>
</div>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.