angular-img-fallback
angular-img-fallback copied to clipboard
Fallback-src doesn't set the fallback image if the src is empty
When the binding value for ng-src is null, src is not set and the fallback img is not set. This happens when loading the url from database and the url is not set for example.
$scope.someUrl = null;
...
<img ng-src='{{someUrl}}' fallback-src />
The fallback-src could check for the 'src' attribute and run the fallback handler if no src is set.
Use ng-src
without brackets.
<img ng-src="user.picture || user.pictureURL" fallback-src="{{'img/user/default-avatar-male.png'}}" style="width: 20vw" />
This worked for me.