onErrorSrc directive for images
This commit is contained in:
parent
e6bba9e20e
commit
abed869052
|
@ -0,0 +1,17 @@
|
|||
import {module} from '../module';
|
||||
|
||||
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);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
module.directive('onErrorSrc', onErrorSrc);
|
Binary file not shown.
After Width: | Height: | Size: 2.1 KiB |
Loading…
Reference in New Issue