title: Timeout function in angularJS
body: <p>I am trying to implement a simple timer in angularJS. But timeout function is not working though it is suggested by everyone.</p>
  
  <pre><code>&lt;!doctype html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
  &lt;script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js"&gt;&lt;/script&gt;
  &lt;script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular-sanitize.min.js"&gt;&lt;/script&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;div ng-app="ss" ng-controller="mainCtrl"&gt;
  {{timeInMs}}
  &lt;/div&gt;
  
  &lt;script&gt;
  var myApp = angular.module("ss", ['ngSanitize']);
  myApp.controller('mainCtrl', function ($sce, $scope) {
  
      $scope.timeInMs = 10;
  
          var countUp = function() {
              $scope.timeInMs+= 500;
              $timeout(countUp, 500);
          }
  
         $timeout(countUp, 500);
  
  
  });
  
  &lt;/script&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>When I comment out the "  $timeout(countUp, 500);" line, the code works without error but timer doesn't work. Do i need to include any more javascript file? </p>
  
  <p>Thanks in advance. </p>