<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8" />
  <title>$interval vs. $timeout angularjs</title>
  <script src="https://code.angularjs.org/1.3.15/angular.js"></script>
  <script>
    var app = angular.module("IntervalApp", []);

     // $timeout service should be injected into a controller function.
    app.controller("IntervalCtrl", function($scope, $timeout) {

      $scope.count = 0;

      $scope.schedulingForTimeout = function() {

        $scope.count += 1;

        // Call the $timeout function call after 5 seconds. Its single call after 5 second.
        $timeout(function() {
          $scope.schedulingForTimeout();
        }, 1000);
      }

      $timeout(function() {
        $scope.schedulingForTimeout();
      }, 1000);

    });
  </script>
</head>

<body ng-app="IntervalApp" ng-controller="IntervalCtrl">
  <div>$interval vs. $timeout angularjs</div>
  The counter : {{count}}
</body>

</html>
// Code goes here

/* Styles go here */