title: Stop AngularJS auto refresh when clicking an HTML element
body: <p>I base my code from this post <a href="https://stackoverflow.com/questions/18416458/angularjs-ngcontroller-to-be-reloading-data-periodically">AngularJS ngcontroller to be reloading data periodically</a> on reloading data every 3 seconds.</p>
  
  <p>My problem now is, when I click something, I want to stop the auto refresh. After that, the auto refresh will start again.</p>
  
  <p>Say for example, when I click a button stop, the auto refresh will stop. and when i click button start it will start fetching data again every 3 seconds.</p>
  
  <p>here's my js</p>
  
  <pre><code>var newsfeed = angular.module('newsfeed',[]);
  
  newsfeed.controller('newsfeedController',function($scope,$http){
       var getPosts = function(){
          $http.get('http://localhost/must_sns/main/all_status').success(function(data){
                  $scope.posts = data;
                  console.log(data);
          }); 
      }
      getPosts();
      setInterval(getPosts, 3000);
  });
  </code></pre>