Reputation: 1144
I have a created a basic image slider which works well.
I am trying to make attempts to add the angular $interval
service to my function in order for the slide to transition automatically.
Does any know how this can be achieved I am assuming this function only requires one or two lines of code. I've also Plunkr
// JOBS FLICKR FUNCTIONS
$scope.jobNotification = 0;
var timer = $interval();
$scope.isActive = function (index) {
return $scope.jobNotification === index;
};
$scope.showJobNotification = function (index) {
$scope.jobNotification = index;
};
I've quite a few versions in bootstrap, however i trying to build something manually so i can understand what i am doing.
Upvotes: 1
Views: 553
Reputation: 17269
$interval takes in a function which will be called every X seconds.
var timeBetweenEachInterval = 5 * 1000; //5 seconds (or 5000 milliseconds)
var intervalPromise = $interval(function () {
//This function will be called every 5 seconds.
index = index + 1;
if (/*don't need interval anymore*/) {
$interval.cancel(intervalPromise);
}
}, timeBetweenEachInterval);
Upvotes: 1