2

This is my working Pagination:

http://plnkr.co/edit/WmC6zjD5srtYHKopLm7m

Here is a summary of my code:

var app = angular.module('hCms', []);
app.controller('samplecontoller', function ($scope,  $http) {   
    $scope.showData = function(){   
        $scope.method = 'GET';
        $scope.url = 'homes.json';
        $scope.code = null;
        $scope.response = null;
        $scope.curPage = 0;
        $scope.pageSize = 3;

        $http({method: $scope.method,url: $scope.url}).
            success(function(data, status) {
                $scope.status = status;
                $scope.datalists = data;
            }).
            error(function(data, status) {
                $scope.datalists = data || "Request failed";
                $scope.status = status;
            });

        $scope.numberOfPages = function() {
            return Math.ceil($scope.datalists.length / $scope.pageSize);
        };

    }

});

angular.module('hCms').filter('pagination', function()
{
    return function(input, start)
    {
        start = +start;
        return input.slice(start);
    };
});

Code works with no issues. Now if you please type in the search field "Dis" which there is an entry for it under page 3. Search brings nothing. I need to run the search on the $scope.datalist at the controller(I think) not as a filter.

Can someone please put me in the right direction or suggest some info in this matter?

Thanks guys,

H.

1 Answer 1

3

I've had this problem - you have to filter the data using search before you paginate it.

      <li class="paginationclass" ng-repeat="datalist in datalists | filter:search | pagination: curPage * pageSize | limitTo: pageSize ">
Sign up to request clarification or add additional context in comments.

1 Comment

YOU BEAUTY. Thanks mate.

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.