You can use $interval(fuctionToRepeat, intervalInMillisecond)
as documented here.
var myPr = angular.module('myPr',[]);
myPr.controller("TodosController", function ($scope,$http){
$scope.reload = function () {
$http.get('http://localhost:3000/api/todos').
success(function (data) {
$scope.todos = data.todos;
});
};
$scope.reload();
$interval($scope.reload, 5000);
});
Actually, the most Angular way to do that would be:
function MyCtrl($scope, $interval) {
$scope.rand = 0;
function update() {
$scope.rand = Math.random() * 10;
}
$interval(update, 1000);
}
That's the Angular equivalent of setInterval()