I base my code from this post AngularJS ngcontroller to be reloading data periodically on reloading data every 3 seconds.
My problem now is, when I click something, I want to stop the auto refresh. After that, the auto refresh will start again.
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.
here's my js
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);
});