Forcing a ng-src reload

前端 未结 5 816
生来不讨喜
生来不讨喜 2020-12-07 21:59

How can I force angularjs to reload an image with an ng-src attribute, when the url of the image has not changed, but its contents has?

5条回答
  •  误落风尘
    2020-12-07 22:41

    Perhaps it could be as simple as adding a decache query string to the image URL? ie.

    var imageUrl = 'http://i.imgur.com/SVFyXFX.jpg';
    $scope.decachedImageUrl = imageUrl + '?decache=' + Math.random();
    

    This should force it to reload.

提交回复
热议问题