设置 Angular 重复限制

Setting an Angular ng-repeat limit

我正在尝试对我的幻灯片设置限制,因为我已经添加了 data-ng-repeat="job in jobs | limitTo : 10"我注意到 12 张幻灯片仍在显示。是不是我的代码有什么不正确的,这个函数不能工作 Plunkr

 var timer;
$scope.startAuto = function() {
    timer = $interval(function(){
        $scope.jobNotification = ($scope.jobNotification + 1) % $scope.jobs.length;
    }, 5000);
};

$scope.isActive = function (index) {
    return $scope.jobNotification === index;

 };

    $scope.showJobNotification = function (index) {
    if (timer){
        $interval.cancel(timer);
        $scope.startAuto();
    }
    $scope.jobNotification = index;
};

$scope.stopAuto = function() {
  console.log('tickCtrl.stopAuto() triggered');
  if(timer) {
  $interval.cancel(timer);
  timer = undefined;        
  }
}

您需要限制jobNotification 值。将模数减少到 10 可防止幻灯片 11 和 12 显示。

$scope.jobNotification = ($scope.jobNotification + 1) % 10;