Смарт-таблицы нумерации страниц не работают

0

У меня ниже HTML:

<table st-table="displayedCollection" 
       st-safe-src="rowCollection" 
       class="table table-striped" 
       st-pipe="callServer">
    <thead>
        <tr>
            <th st-sort="id">id</th>
            <th st-sort="name">name</th>
        </tr>
    </thead>
    <tbody ng-show="!isLoading">
        <tr ng-repeat="row in displayedCollection">
            <td>{{row.id}}</td>
            <td>{{row.name}}</td>
        </tr>
    </tbody>
    <tbody ng-show="isLoading">
        <tr>
            <td colspan="2" class="text-center">Loading ... </td>
        </tr>
    </tbody>
    <tfoot>
        <tr>
            <td class="text-center" colspan="2">
                <div 
                    st-template="templates/plugins/pagination.html" 
                    st-pagination="" 
                    st-items-by-page="10" 
                    class="ng-isolate-scope">
                </div>
            </td>
        </tr>
    </tfoot>
</table>

У меня есть код в контроллере:

$scope.callServer = function callServer(tableState) {
        var pagination = tableState.pagination;
        var start = pagination.start || 0;
        var size = pagination.number || 10;
        console.log('tableState:', tableState);

        $scope.isLoading = true;
        TestSuiteService.getPage(start, size, tableState).then(function (response) {
            $scope.rowCollection = response.results;
            $scope.displayedCollection = [].concat($scope.rowCollection);
            tableState.pagination.numberOfPages = response.numberOfPages;
            $scope.isLoading = false;
        });
    };

У меня ниже st-template

<div class="pagination" ng-if="pages.length >= 2">
    <ul class="pagination">
        <li ng-if="currentPage > 1">
            <a ng-click="selectPage(1)">&lt;&lt;</a>
        </li>
        <li ng-if="currentPage > 1">
            <a ng-click="selectPage(currentPage-1)">&lt;</a>
        </li>
        <li ng-repeat="page in pages" ng-class="{active: page==currentPage}">
            <a ng-click="selectPage(page)">{{page}}</a>
        </li>
        <li ng-if="currentPage < numPages">
            <a ng-click="selectPage(currentPage+1)">&gt;</a>
        </li>
        <li ng-if="currentPage < numPages">
            <a ng-click="selectPage(numPages)">&gt;&gt;</a>
        </li>
    </ul>
</div>

Когда я нажимаю на страницу, он извлекает данные с сервера и отображает их в таблице, но страница не выбирается. Из-за этой предыдущей страницы и ссылки на последнюю страницу также не отображаются. Страница 1 всегда остается активной.

Теги:
smart-table

1 ответ

0
Лучший ответ

Я удалил атрибут st-safe-src из table поэтому в моем случае мне пришлось удалить st-safe-src="rowCollection" чтобы он работал.

Ещё вопросы

Сообщество Overcoder
Наверх
Меню