I have this working implementation af a angularJS app which fetches some links from an URL and paint them. However the links on the URL are being updated constantly, I woul
$interval is made for this:
$interval(function() {
// your stuff
}, 1000);
Don't forget to inject $interval
in your controller
app.controller('ExampleController', ['$scope', '$interval',function($scope, $interval) {
$interval(function() {
// your stuff
, 1000);
}]);
https://docs.angularjs.org/api/ng/service/$interval
A better solution is to use Angular $interval and $destroy providers Example:
var stop=$interval(function () {
function_call();
}, 12000)
$scope.stopInterval = function () {
if (angular.isDefined(stop)) {
$interval.cancel(stop);
stop = undefined;
}
};
$scope.$on('$destroy', function () {
// Make sure that the interval is destroyed too
$scope.stopInterval();
});