4

Problem

Data are loaded asynchronously and displayed correctly, but pagination does not appear. Thank you if you can help.

HTML

<table st-safe-src="update" st-table="displayedItemList" class="table table-striped table-bordered">
    <thead>
        <tr>
            <th>Field1</th>
            <th>Field2</th>
        </tr>
    </thead>
    <tbody>
        <tr ng-repeat="item in displayedItemList">
            <td>{{item.Field1}}</td>
            <td>{{item.Field2}}</td>
        </tr>
    </tbody>
    <tfoot>
        <tr>
            <td colspan="2" class="text-center">
                <div st-pagination="" st-items-by-page="10" st-displayed-pages="7"></div>
            </td>
        </tr>
    </tfoot>
</table>

JavaScript

    $scope.itemList = [];
    $scope.displayedItemList = [];
    $scope.update = 0;

    $scope.initialize = function ()
    {
        var d = new $.Deferred();

        itemService.getItems().then(function (data) {
            $scope.itemList = data;
            $scope.displayedItemList = [].concat($scope.itemList);
            $scope.update++;
            d.resolve();
        });

        return d;
    }

Alternative tried

... same result.

    <table st-safe-src="itemList" ...
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
TTT
  • 1,848
  • 2
  • 30
  • 60
  • 1
    if you have only one page in your dataset, the pagination will not show. how many items itemList does have ? – laurent Jul 14 '15 at 22:15
  • 43 items. I think the problem is with the async aspect. But I switched back from Smart Table to Angular UI Grid for wich one of my colleagues already had draft code (and doesn't display pagination either). – TTT Jul 15 '15 at 07:41

1 Answers1

0

in the controller, you need to fill in the st-safe-src (update), not displayedItemList. I mean, for example

$scope.update = $scope.itemList; 
MatejMecka
  • 1,448
  • 2
  • 24
  • 37
All
  • 1
  • 1