AngularJs setinterval ($interval)

The $interval service is similar in function to the $timeout service, except it schedules a function for repeated execution with a time interval in between.

by sqiudward

HTML

<div ng-app="app" ng-controller="mainCtrl">
  <div>
    {{countdown}}
  </div>
</div>

JavaScript

(function(){
	var app = angular.module("app", []);
  
	var mainCtrl = function($scope,$http,$interval){
    $scope.countdown = 120; //30years
    
    var decrementCountdown = function(){
      	$scope.countdown +=1;
        
        if($scope.countdown <1){
        	
        }
      };
      
      var startCountdown = function(){
				$interval(decrementCountdown, 1000, $scope.countdown);
      }
      startCountdown();
      
  };
  
  app.controller("mainCtrl", mainCtrl);
}());