title: Call server every 5 seconds - returns stack overflow error
body: <p>I want to call a method on an interval of time. I am receiving stack overflow error. What am I doing wrong:</p>
  
  <p>html: </p>
  
  <pre><code>&lt;div ng-app="myApp" ng-controller="Ctrl"&gt;
      &lt;span&gt;{{calledServer}}&lt;/span&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>js: </p>
  
  <pre><code>var app = angular.module('myApp', []);
  
  app.controller("Ctrl", function($scope, repo, poollingFactory) {
      $scope.calledServer;
      $scope.calledServer = poollingFactory.callFnOnInterval(function() {return repo.callServer(5);});
  });
  
  app.factory("repo", function() {
  
      function callServer(id){
          return "call server with id " + id;   
      }
  
      return {
          callServer: callServer
      };
  });
  
  app.factory("poollingFactory", function($timeout) {
  
      var timeIntervalInSec = 5;
  
      function callFnOnInterval(fn, timeInterval) {
  
          $timeout(callFnOnInterval, 1000 * timeIntervalInSec);
          callFnOnInterval(fn, timeIntervalInSec);
      };
  
      return {
          callFnOnInterval: callFnOnInterval
      };
  });
  </code></pre>
  
  <p>jsfiddle: <a href="http://jsfiddle.net/fq4vg/423/">http://jsfiddle.net/fq4vg/423/</a></p>