salix/client/core/src/directives/on-error-src.js

17 lines
443 B
JavaScript
Raw Normal View History

2018-02-10 15:18:01 +00:00
import ngModule from '../module';
2018-01-25 12:37:27 +00:00
function onErrorSrc() {
return {
restrict: 'A',
link: (scope, element, attrs) => {
let imgError = '/static/images/no-image200x200.png';
element.bind('error', function() {
if (attrs.src != imgError) {
attrs.$set('src', imgError);
}
});
}
};
}
2018-02-10 15:18:01 +00:00
ngModule.directive('onErrorSrc', onErrorSrc);