title: Stop time interval during navigation in angularjs
body: <p>Currently i am using angular js</p>
  
  <p>I have one get method to get data from server side in <code>default.html</code> page </p>
  
  <pre><code>function bindActiveLoans() {
              $http.get(rootUrlSingleEscaped + '/cooperativa/allunfundedloans/?authId=' + userInfo.UserId)
                   .success(function (response) {
                       if (response.Loans.length == 0) {
                           $scope.IsValues = false;
                           $scope.$apply();
                           return true;
                       }
                       $scope.IsValues = true;
                       $scope.unfundedLoans = response;
                   });
          };
  
          setInterval(function () {
              $scope.$apply(bindActiveLoans());
          }, 5000);
  </code></pre>
  
  <p>The above function helps to get the data from server side method in every 5 seconds.</p>
  
  <p>Here, I  have an issue.</p>
  
  <p>Additionally I have some more pages, like </p>
  
  <ul>
  <li><p>default2.html,default3.html,default4.html,default5.html.</p>
  
  <blockquote>
    <p>The timer is still running while i navigation <code>default.html</code> page to <code>default1.html</code> page. I want to only that timer running in <code>default.html</code> page.If i go to another page,then the timer should stop. How can we achieve it? </p>
  </blockquote></li>
  </ul>