2015-05-18 105 views
-1

如何使用角度js服务器端过滤器?我已经尝试了下面的代码,我现在可以做分页,但我不能做一个过滤器。如何制作角度js服务器端过滤器

var app = angular.module('myApp', ['ui.bootstrap']); 

app.filter('startFrom', function() { 
    return function(input, start) { 
     if (input) { 
      start = +start; //parse to int 
      return input.slice(start); 
     } 
     return []; 
    } 
}); 
app.controller('customersCrtl', function($scope, $http, $timeout) { 
    $scope.currentPage = 1; 
    $http.get('ajax/getCustomers.php?limit=' + $scope.currentPage).success(function(data) { 
     $scope.list = data; 
     $scope.currentPage = 1; //current page 
     $scope.entryLimit = 5; //max no of items to display in a page 
     $scope.filteredItems = $scope.list[0].total; //Initially for no filter 
     $scope.totalItems = $scope.list[0].total; 
    }); 
    $scope.setPage = function(pageNo) { 
     $scope.currentPage = pageNo; 

    }; 
    $scope.filter = function() { 
     $timeout(function() { 
      $scope.filteredItems = $scope.filtered.length; 
     }, 10); 
    }; 
    $scope.sort_by = function(predicate) { 
     $scope.predicate = predicate; 
     $scope.reverse = !$scope.reverse; 
    }; 
}); 
+0

看看这可能是有用的http://stackoverflow.com/questions/14696008/angular-js-server-side-filter-and-pagination – Reena

回答