Try to load an image, but if it doesn’t exist instead load another image.
# .html
<img
[src]="getImage(v)"
alt="Photo of {{ v.name }}"
(error)="errImage($event, v)"
/>
Code language: HTML, XML (xml)
# .ts
errImage(e: any, v: any): void {
e.target.src = this.getAltImage(v);
}
Code language: PHP (php)