0
は私の改ページコードで助けを必要と動作しません(http://plnkr.co/edit/Jv12fcBzm3lvZFqHqDJm?p=preview)スマート表の改ページが
私のデータは、巨大な(> 1000K行)です。私は目に見える記録(ページあたり50行)だけを要求したい。ユーザーが並べ替えやページの変更を行うたびにRESTサービスコールを要求します。
私のコードでは、例を単純化するために$ http.post()を$ timeoutに置き換えました。
angular.module('app',['smart-table'])
.controller('mainCtrl',['Resource', function (service) {
var ctrl = this;
this.rowCollection = [];
this.totalMatched = 0;
this.totalExecutionTime = 0;
this.paginationStart = 0;
this.callServer = function callServer(tableState) {
ctrl.isLoading = true;
var pagination = tableState.pagination;
console.log(pagination.number);
var start = pagination.start || 0;
var number = pagination.number || 5;
service.getPage(start, number, tableState).then(function (result) {
var tstamp = new Date().getTime();
console.log('Requesting page: '+start+', '+number+','+tstamp);
ctrl.rowCollection = result.data.items;
ctrl.totalMatched = result.data.total;
ctrl.paginationStart = start;
tableState.pagination.numberOfPages = result.numberOfPages;//set the number of pages so the pagination can update
ctrl.isLoading = false;
});
};
}])
.factory('Resource', ['$q', '$filter', '$timeout', '$http', function ($q, $filter, $timeout, $http)
{
function getPage(start, number, params) {
var deferred = $q.defer();
$timeout(function() {
deferred.resolve({
data: {total:8000, items:[{message:'foo',messagetime:'2016-01-01'},{message:'foobis',messagetime:'2016-02-02'}]},
numberOfPages: Math.ceil(1000/number)
});
}, 1500);
return deferred.promise;
}
return {
getPage: getPage
};
}
]);
私は間違っていますか?どんな助けでも大変感謝しています。 script.jsで
st-safe-srcをstパイプと一緒に使用する必要はないことに気付きました。私はst-safe-srcを削除して動作し始めました。 – zuko