A problem with ng-src in AngularJS

A problem with ngSrc:

The image doesn't reload/change itself if the new/updated image has the same URL as the old image.


Use cache buster to force reloading image. Example:

<img ng-src="{{imageSource}}" alt=""/>
angular.module('ngSrcDemo', [])
    .controller('AppCtrl', ['$scope', function ($scope) {
    $scope.app = {
        imageUrl: "http://example.com/img.png"
    var random = (new Date()).toString();
    $scope.imageSource = $scope.app.imageUrl + "?cb=" + random;

Yang Zhao

Read more posts by this author.