I'm still learning AngularJS and I have a specific question regarding page refresh only when new data is fetched from the server.
I've looked for solutions online, but haven't come across anything that fits my issue.
Below is my Service and Controller with an intervalPromise setup:
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();
}
The data is successfully retrieved from the server every 10 seconds, but I want to trigger a page refresh only if there's new data available.
Any guidance on how to achieve this would be highly appreciated.