Bug fixed, the problem was that $ scope.imageURL = ' http: //mywebsite/assets/now.png? _Ts = ' + new Date (). getTime (); absent in the function of success. Basically, I needed to update the image URL. I'm not sure if this is the best solution, but it works for my requirements.
<div ng-app="refresh-div" ng-controller="refresh_control">
<img ng-src="{{imageURL}}" />
</div>
<script>
var app = angular.module('refresh-div', [])
.controller('refresh_control', function ($scope, $http, $timeout) {
$scope.imageURL = 'http://mywebsite/assets/now.png?_ts=' + new Date().getTime();
$scope.getImage = function () {
$http.get($scope.imageURL, {
cache: false
}).success(function (data, status, headers, config) {
$scope.imageURL = 'http://mywebsite/assets/now.png?_ts=' + new Date().getTime();
});
};
$scope.intervalFunction = function () {
$timeout(function () {
$scope.getImage();
$scope.intervalFunction();
}, 1500)
};
$scope.intervalFunction();
});
</script>
source
share