Launch offer
Business website $150 USD Custom plugin $200 USD Ready in 5 days
Get a quote
AngularJS

$interval Service in AngularJS

Schedule repeating work with $interval and cancel on destroy.

$interval Service in AngularJS — a practical guide to AngularJS $interval with clear examples you can reuse in real projects.

AngularJS Tutorial Series (44/99). Prefer one article? Read the complete AngularJS tutorial.

Short description

Always cancel intervals to avoid leaks.

$interval

var tick = $interval(function () {
  vm.now = new Date();
}, 1000);
$scope.$on('$destroy', function () {
  $interval.cancel(tick);
});

Leave a reply

Your email address will not be published. Required fields are marked *