myCode myCode - 2 years ago 117
AngularJS Question

How to search through all Paginated entry with AngularJs?

I am using Jhipster. The Project has been generated with pagination. I need to search through all The IDs( entries), when I am searching anything, its only searching between the first 20 entries. how can I search through all entries ? is it possible to do with angularjs ? or it has to be done from server side ?

Given deafult loadAll() function:

$scope.loadAll = function() {
DataEntry.query({page: $scope.page - 1, size: 20, sort: [$scope.predicate + ',' + ($scope.reverse ? 'asc' : 'desc'), 'id']}, function(result, headers) {
$scope.links = ParseLinks.parse(headers('link'));
$scope.totalItems = headers('X-Total-Count');
$scope.bundles = result;
});
};


I have tried so far

$scope.commonID = 1; //
$scope.newSetOfData = [];
$scope.searchNsort =function(){
DataEntry.query(function(result){
angular.forEach(result , function(dataResponse){
if(dataResponse.id == $scope.commomID){
$scope.newSetOfData.push(m);
}
});
});
return $scope.newSetOfData;
};

Answer Source

On ng-change of search field I called this filterData function.$scope.data contain complete data.$scope.searchValue contain search value.I have set currentpage, numberperpage in $scope variable.This code is working for me.

 $scope.filterData = function(){

    if ($scope.data != undefined) {
        var filterData = $filter('filter')($scope.data,$scope.searchValue);
        var begin = (($scope.currentPage - 1) * $scope.numPerPage)
        end = begin + $scope.numPerPage;
        $scope.data1 = filterData.slice(begin, end);
    }
  };
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download