我一直试图实现这个AngularJS表格分页http://jsfiddle.net/EnY74/20/问题现在我已将它插入到网站中减去css引导程序,分页显示1,222个条目时应该只有大约12个条目。我也是javascript的新手。
它复制条目20次或者其他东西然后复制第二个条目20次,依此类推。
看看这里jsfiddle.net/vsfsugkg/1只更改了行的条目,它们重复1,222次?我认为内容是从其他地方撤出的?
这是JS文件的内容。
'use strict';
var App = angular.module('PaginationApp', []);
App.controller('MainCtrl', ['$scope', 'TypekitService', '$filter', function($scope, Typekit, $filter){
$scope.loadData = function(){ Typekit.getTypekits($scope.page, $scope.per_page).then(function(response){
$scope.more = response.data.library.families.length === $scope.per_page;
$scope.families = $scope.families.concat(response.data.library.families);
$scope.status_bar = "Showing " + ($scope.families.length === 0 ? "0" : "1") + " to " + $filter('number')($scope.families.length) + " of " + $filter('number')(response.data.library.pagination.count) + " entries";
});
};
$scope.show_more = function(){
$scope.page += 1;
$scope.loadData();
}
$scope.has_more = function(){
return $scope.more;
}
$scope.per_page = 10;
$scope.page = 1;
$scope.families = [];
$scope.more = true;
$scope.status_bar = "";
$scope.loadData();
}])
App.factory('TypekitService',['$http',function($http){
return {
getTypekits : function(page, per_page){
return $http.jsonp('https://typekit.com/api/v1/json/libraries/full?page='+page+'&per_page='+per_page+'&callback=JSON_CALLBACK');
}
}
}]);