Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AngularJS $timeout loop fires only once

I have the following, but what I'm trying to do is have the $timeout loop every 10 seconds, but what the below is doing is running the shuffleArray() then after 10 seconds it fires it again and that is it. It stops there.

    $http.post("/content", {"Data":JSON.stringify($scope.content)}).success(function(data, status, header, config){
        $scope.ourcontent = data;
        shuffleArray($scope.ourcontent);
        $timeout(function() {
            shuffleArray($scope.ourcontent);
        }, 10000);
    });
like image 250
ngplayground Avatar asked Jul 21 '14 12:07

ngplayground


1 Answers

What you need is $interval, have a look here.

like image 196
Adrian Neatu Avatar answered Nov 10 '22 20:11

Adrian Neatu