In Angular2, suppress chrome console errors for image not found
so I have this code:
<div *ngIf="defaultImage">
<img [ngStyle]="_style.img" [ngClass]="{'img-circle': circle}" [src]="getImageUrl()" (load)="onImageLoaded()" (error)="onImageError()" />
</div>
so I have this function that looks for images online, and if an image is not found I catch the error and take action. However I am seeing an annoying console error which I would like to suppress when I am developing as its just of an annoyance, is it possible?
see below:
regards
Sean
There is no way to suppress this error. This is browser default behavior.
If your server provides an API where you can query in advance if the file exists, that could be done. That check must not result in a 404 in case the image doesn't exist, or the check would just result in the same console log output.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With