I am quiet new to AngularJS and have a quick question about refreshing a page only when new data is retrieved from the server.
I have searched around but couldnt find anything similar to my problem.
I have a Service and Controller with an intervalPromise as follows:
MyService
angular.module('MyService', ['ngResource']).
factory('Data', function($resource){
return $resource('rest/getMyData', {});
});
MyController
function MyController($scope,$interval,$http, Data) {
$scope.refresh = function() {
$scope.jobs = Data.query();
};
$scope.intervalPromise = $interval(function(){
$scope.refresh();
}, 10000);
// initial load of data
$scope.refresh();
}
Data is retrieved from the server successfully every 10 seconds, but I would like the page to refresh only when new data is found.
A point in the right direction would be much appreciated.