Context of the question:
I'm using the solution from this question: How to update AngularJS view when the value has not changed? So in my view I have:
<img ng-src="{{user.photo.pathRelative}}{{randomStr}}" alt=""/>
when I change the photo I run the following code in my contoller:
$scope.user.photo.pathRelative = somePathToPhoto;
$scope.randomStr = '?randomStr=' + new Date().getTime();
This results in the following html (and everyting works as it should):
<img ng-src="img/profiles/5350f142dd9624b818d90007/5350f142dd9624b818d90007.png?randomStr=1398159116845" alt="" src="img/profiles/5350f142dd9624b818d90007/5350f142dd9624b818d90007.png?randomStr=1398159116845">
Question:
Now I want to allow user to delete this photo, so when he hits the delete button I do:
$scope.user.photo.pathRelative = '';
$scope.randomStr = '';
However, this results in the following html:
<img ng-src="" alt="" src="?randomStr=1398159116845">
So src attribute is still set, hence the browers tries to render it but obviously the path is not valid.
Any hints why this src is set to incorrect value?