Hi,

1down votefavorite 
<http://stackoverflow.com/questions/40605162/angularjs-filters-from-only-first-page#>

I have a simple code which get employees from controller and I want to 
filter these records with pagination. When I filter from first page 
everything works fine but, when I want to filter from other page it does 
not filter and shows nothing.

My code is as follow:

-filter.js

angular.module('MyApp', ['ui.bootstrap']).controller('MyController', function 
($scope, EmployeesService) {
    $scope.Employees = null;
    $scope.currentPage = 1; 
    $scope.pageSize = 2;
    $scope.maxSize = 100;


    EmployeesService.GetEmployees().then(function (d) {
        $scope.Employees = d.data; // Success

    }, function () {
        alert('Failed'); // Failed
    })})
.service('EmployeesService', function ($http) {
    var service = {};
    service.GetEmployees = function () {
        return $http.get('/Employees/GetEmployees');
    }
    return service;}).filter('start', function () {
    return function (input, start) {
        if (!input || !input.length) { return; }
        start = +start;
        return input.slice(start);

    };});

-Index.cshtml


<div ng-app="MyApp">
    <div ng-controller="MyController">

        <input type="text" ng-model="filterText" name="searchString" 
placeholder="Search for names.." class="form-control"><br />

        <div ng-repeat="emp in Employees |orderBy: 'employeeName'| filter: 
filterText | start: (currentPage-1) * pageSize | limitTo: pageSize"
             class="alert alert-warning col-md-12">    

            <span ng-bind="emp.employeeName"></span> <b>:</b>
            <span ng-bind="emp.employeePhoneNumber"></span>

        </div>
        <pagination ng-model="currentPage" total-items="Employees.length" 
items-per-page="pageSize"></pagination>
    </div></div>

Thank you in advance.


-- 
You received this message because you are subscribed to the Google Groups 
"Angular" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to