Created
May 8, 2017 14:18
-
-
Save MaxXxiMast/6a56675f42dc2a007cf463e789f3c2ba to your computer and use it in GitHub Desktop.
Replace a 404 Image with a default image in Angular
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<img ng-if="product.image" ng-src="{{product.image}}" alt="{{product.name}}" onerror="angular.element(this).scope().product.image = false"> | |
<img ng-if="!product.image" ng-src="http://placehold.it/{{vm.image.width}}x{{vm.image.height}}" alt="{{product.name}}"> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment