How To Update Angularjs View When The Value Has Not Changed?
In my view I diplay a photo from the user's profile, in my view I have: When user uploads new photo it is uploaded to th
Solution 1:
You need to be using ng-src (just an FYI).
<imgng-src="{{user.photo.pathRelative}}{{randomStr}}"/><br/>
And then you set random string after the upload.
$scope.randomStr = '?randomStr=' + newDate().getTime();
The downside is this will not work after refresh...
You could also combine the two if you want like @Tom mentioned below. I do not like doing this, bc you are modifying potentially an "object" that could be saved. For instance if you are using ng-resource and you modified pathRelative and then $save, it would result in the pathRelative being updated in the database.
Solution 2:
The problem is that the image is cached. To fix this, you could set pathRelative to the path + the current date, like:
$scope.user.photo.pathRelative = "/somePath?" + newDate().getTime();
And update that when it changes
Post a Comment for "How To Update Angularjs View When The Value Has Not Changed?"