Search code examples
angularjssearchpaginationsmart-table

Angular Smart table search and pagination not working


I am new in angular. I tried first time smart table by looking its documentation. I am facing problem while in search and pagination. I tried to look various solutions on stack overflow but no success. Please help

<table st-table="displayedCollection" st-safe-src="rowList" class="table table-stripped">
<thead>
    <tr>
        <th st-sort="engagement_id">Engagement Id</th>
        <th st-sort="customer_name">Customer Name</th>
    </tr>
    <tr>
        <th colspan="8">
            <input st-search placeholder="global search" class="input-sm form-control" type="search" />
        </th>
    </tr>
</thead>
<tbody>
    <tr ng-repeat="data in displayedCollection">
        <td>{{data.engagement_id}}</td>
        <td>{{data.customer_name}}</td>
    </tr>
</tbody>
<tfoot>
    <tr>
        <td colspan="5" class="text-center">
            <div st-pagination="" st-items-by-page="5" colspan="8"></div>
        </td>
    </tr>
</tfoot>

here is angular code

$.post(MY_CONSTANT.url + '/all_rides', {
        access_token: $cookieStore.get('obj').accesstoken,
        start_limit: start_limit,
        end_limit: end_limit

    }, function (data) {
        $scope.showloader=false;

        if (data.status == true) {
            var rides = data.data[1];
            $scope.rowList = rides;
            $scope.displayedCollection = [].concat($scope.rowList);
        }
        else if (data.status == responseCode.INVALID_ACCESS_TOKEN){
            $state.go('page.login');
        }
    });

using smart table cdn here is link: https://cdnjs.cloudflare.com/ajax/libs/angular-smart-table/2.1.8/smart-table.min.js">


Solution

  • Your posted code seems not to have problem if you can get 'rowList' from your server.

    So, please check if you can add smart table library.

    angular.module('appName', ['smart-table'])