.directive('fallbackSrc',[
function(){
return {
link: function(scope,element,attrs){
element.bind('error', function(e){
element.attr('src', attrs.fallbackSrc)
})
}
}
}
])
<img src="/some/image.png" fallback-src="/another/fail-safe-image.png">
Inside the function, "element" is a jquery-lite wrapped object so jquery's functionality is already there. All it does is on the error event, is set the element's src attribute to the fallbackSrc attribute.
You can keep reading tutorials until your heart is content, but I gained real understanding by jumping in, copying others ideas, then tweaking it, etc, until the pieces bean to make more sense.
Good luck!