born2net
born2net

Reputation: 24953

In Angular2, suppress chrome console errors for image not found

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: enter image description here

regards

Sean

Upvotes: 5

Views: 810

Answers (1)

G&#252;nter Z&#246;chbauer
G&#252;nter Z&#246;chbauer

Reputation: 657278

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.

Upvotes: 5

Related Questions