Skip to content

Instantly share code, notes, and snippets.

@MaxXxiMast
Created May 8, 2017 14:18
Show Gist options
  • Save MaxXxiMast/6a56675f42dc2a007cf463e789f3c2ba to your computer and use it in GitHub Desktop.
Save MaxXxiMast/6a56675f42dc2a007cf463e789f3c2ba to your computer and use it in GitHub Desktop.
Replace a 404 Image with a default image in Angular
<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