I have implemented a custom directive that loads a backup image source if the initial one returns a 404 error. Here is the code for the directive:
.directive('errSrc', function() {
return {
link: function(scope, element, attrs) {
element.bind('error', function() {
if (attrs.src != attrs.errSrc) {
attrs.$set('src', attrs.errSrc);
}
});
}
}
While this functionality works well in replacing the image source when needed, I am looking for a way to suppress the repetitive 404 error messages generated in the console. It becomes difficult to debug with so many of these messages appearing consecutively. Is there a way to handle this within the directive?