Q:

Angular How to use $interval without delay during first run? 

I have the following function which is animating some object on the screen:
$interval(function() {
    $('#cloudLeftToRight').animate({
        left: '+=250%',
    }, 7000, function() {
        $('#cloudLeftToRight').removeAttr('style');
        $scope.resetAnimationCloudLeftToRight();
    });
}, 8000);

Problem is that if app function is triggered first animation is displayed after the 8 sec.  delay. 
I would like to run animation immediately after the function is triggered and after that repeat animation each 8 sec.  
It occurred to me one solution:
Make the timer and animation function separated and after init call only animation function and immediately call the timer function where should be passed name of the animation function. 
Any better solution please? 
Many thanks for any advice. 

A:

You could try something like this:
function myFunction(){
  $('#cloudLeftToRight').animate({
    left: '+=250%',
  }, 7000, function () {
    $('#cloudLeftToRight').removeAttr('style');
    $scope.resetAnimationCloudLeftToRight();
  });  
}

myFunction();
$interval(function () {
  myFunction();
}, 8000);

