I found this very nice directive on Medium (https://medium.com/@sub.metu/angular-fallback-for-broken-images-5cd05c470f08):
import {Directive, Input, HostBinding} from '@angular/core'
@Directive({
selector: 'img[default]',
host: {
'(error)':'updateUrl()',
'(load)': 'load()',
'[src]':'src'
}
})
export class ImagePreloadDirective {
@Input() src:string;
@Input() default:string;
@HostBinding('class') className
updateUrl() {
this.src = this.default;
}
load(){
this.className = 'image-loaded';
}
}
However, TSlint tells me I should use HostBinding instead of host on line 4. But I've found no documentation to help me implement this. Can someone help?