bitwarden-desktop/src/app/directives/fallback-src.directive.ts

21 lines
386 B
TypeScript

import {
Directive,
ElementRef,
HostListener,
Input,
} from '@angular/core';
@Directive({
selector: '[appFallbackSrc]'
})
export class FallbackSrcDirective {
@Input('appFallbackSrc') appFallbackSrc: string;
constructor(private el: ElementRef) {
}
@HostListener('error') OnError() {
this.el.nativeElement.src = this.appFallbackSrc;
}
}