我需要向页面添加无限滚动,但loadMore函数在$ scope.model.length中有错误。我怎么能解决这个问题? 这是PLUNKER,但它可以在这里工作......
var myApp = angular.module('myApp', ['localytics.directives', 'infinite-scroll']);
myApp.controller('myCtrl', ['$scope', 'postService',
function ($scope, postService) {
$scope.loadMore = function() {
if ($scope.limits < $scope.model.length) {
console.log($scope.limits);
$scope.limits += 5;
}
};
$scope.bindModel = function (data) {
$scope.limits = 30;
$scope.model = data;
};
$scope.bindUsers = function(data) {
$scope.usersList = data;
};
/* Service that GET data via query */
postService.getTicketsInProgressList($scope.bindModel, 0);
postService.getProjectsMembers($scope.bindUsers);
}
]);
表的一部分,其中loadMore调用,它是无限滚动用法:
<tbody ng-repeat="item in model | limitTo: limits track by $index">
<tr class="timesheet-day-block">
<td colspan="6">
<span class="timesheet-date">{{item.TaskDate | dateFilter}}</span>
</td>
</tr>
<tr class="timesheet-table-rows" ng-repeat="list in item.TimesheetList" ng-form="logged">
<td>{{list.ProjectName}}</td>
<td>{{list.UserName}}</td>
<td>{{list.Date | date: 'dd/MM/yyyy'}}</td>
<td>{{list.Task}}</td>
<td>{{list.TimeWorked}}</td>
<td><span style="width: 85%">{{list.Note}}</span>
<button class="active-delete-button" ng-click="removeTask(list)" style="display: inline-block; float:right">✖</button>
</td>
</tr>
</tbody>