我正在尝试设置幻灯片的限制,因为它已添加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;
}
}
答案 0 :(得分:0)
您需要限制jobNotification值。将模数减少到10可防止幻灯片11和12显示。
$scope.jobNotification = ($scope.jobNotification + 1) % 10;