I had the same problem, I had the <user-picture> directive, and on the user settings page, the user could change his image. The image comes from api, like url + token . When I change the image from the database, I get success, and then I need to update the file ng-src="{{mainCtrl.picture.src}}" on each instance of the directive.
This is the directive:
angular.module('appApp') .directive('userPicture', function() { return { restrict: 'E', template: '<img class="img-responsive" ng-src="{{mainCtrl.picture.src}}" />', controller: 'UserPictureCtrl', scope: true, replace: true } }) .controller('UserPictureCtrl',['$scope', '$resource', 'HelpersService', '$sessionStorage', function ($scope, $resource, HelpersService, $sessionStorage) { $scope.mainCtrl.picture = {}; $scope.mainCtrl.picture.src = HelpersService.domain + 'user/getPictureAsStream?token=' + $sessionStorage.token; }]);
I bind
ng-src="url file address string" to mainCtrl. When I change the picture in the database, I reassign the value of $ scope.mainCtrl.picture.src to the same token + token, but I sow everything to add to the additional parameter
&rand url sow url looks like this:
http://<domain>/<serverApi>/user/getPictureAsStream?token=65145d12-f033-41f1-b101-9ed846352284&rand=0.6513215699 , pay attention to the last parameter
&rand=0.6513215699 . This tells the browser that it is a different file from a different URL and makes a request to the server for it, on the server instead the additional parameter is ignored, it gives me a new image, even if it is in the same place. And also it updates the directory image.
source share