2

この問題の実際の例はplunkerを参照してください。角型UIブートストラップページング - 最初の12レコードをインサイトページロードでng-repatで表示

ページネーションのページ番号をクリックするとページネーションが機能しますが、最初のページ(最初のレコードセット)のデータは最初にロードされません。あなたが数字をクリックする瞬間、それはうまく動作します。

ご注意:上記のplunkerはSO、私の本当のプロジェクトはより複雑であるので、私はちょうど

var app = angular.module('plunker', ['ui.bootstrap.tpls', 'ui.bootstrap.pagination']); 

app.controller('MainCtrl', function($scope, dataService) { 
    $scope.data = []; 

    dataService.getAll() 
      .then(function (response) { 
       // Success 
       $scope.data = response.data; 
       $scope.totalItems = $scope.data.length; 
      }, function (data, status, header, config) { 
       // Failure 
      }); 

    $scope.itemsPerPage = 12; 
    $scope.currentPage = 1; 

    $scope.pageCount = function() { 
    return Math.ceil($scope.data/ $scope.itemsPerPage); 
    }; 

    $scope.$watch('currentPage + itemsPerPage', function() { 
    var begin = (($scope.currentPage - 1) * $scope.itemsPerPage), 
    end = begin + $scope.itemsPerPage; 

    $scope.filtered = $scope.data.slice(begin, end); 
    }); 

}); 

// DataServiceの

(function() { 

"use strict"; 

angular.module("plunker").factory("dataService", dataService); 

function dataService($http) { 

    return { 
     getAll: getAll 
    } 

    function getAll() { 

     return $http.get("http://api.scb.se/OV0104/v1/doris/en/ssd"); 
    } 
} 

})(); 

答えて

2
のDataServiceなどを取り除くカントのためだけのデモです

更新plunker:http://plnkr.co/edit/2yHEukhKZcFplmJaFv0P

追加機能updateView()

この関数は、データが最初に読み込まれ、時計に読み込まれると呼び出されます

+0

ようこそ!幸せ、私は助けることができる – Aks1357

関連する問題