1

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.

1

1 Answer 1

1

$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);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.