Angularjs fallback image directive
Using fallback image with <img> tag is common scenario to show a default image if the original image is not loaded. In angular you can achieve this by creating a fallback directive like below, angular.module(‘fallback’,[]).directive(‘fallbackSrc’, function () { return{ link: function postLink(scope, element, attrs) { element.bind(‘error’, function () { angular.element(this).attr(“src”, attrs.fallbackSrc); }); } } }); […]