ng-table pagination, sorting and filter not working

VishwaKumar picture VishwaKumar · Oct 14, 2014 · Viewed 10.5k times · Source

I am trying to use ngTable but its not working as expected. I've implemented pagination, sorting and filter

Here is a plunker i have created.

I have done same way as specified in the docs examples. The pagination, sorting and filter are not working.

I tried to debug but i am not getting any error messages also

Answer

Fabian picture Fabian · Jan 20, 2016

I'm using a later version of ng-table but was having similar problems. Apparently you need to add show-filter="true" to the table tag. I didn't see this in the documentation/examples for ng-table but found it in the source code tests.

My Angular Version : 1.2.16
My ng-Table Version : 0.8.3

also tried it with

Angular Version : 1.2.28
ng-Table Version : 0.4.3

HTML

<div class="row">
<div class="col-lg-12">
    <table ng-table="tableParams" show-filter="true" class="table table-condensed table-bordered table-striped">
        <tr ng-repeat="candidate in $data">
            <td data-title="'First Name'" filter="{firstName : 'text'}">{{candidate.firstName}}</td>
            <td data-title="'Last Name'"  filter="{lastName  : 'text'}">{{candidate.lastName}}</
        </tr>
    </table>
</div>

JS Controller

controller: function ($scope, Candidates, NgTableParams) {
            var tableParams = {
                count : 15
            };
            var tableSettings = {

            };
            Candidates.getCandidates().then(function (res) {
                tableSettings.data = res.data._embedded.candidates;
                $scope.tableParams = new NgTableParams(tableParams, tableSettings);
            });
        }