8

Don't know why always showing this error for me, but ionic3 project can run as usual.

This is what showing: enter image description hereenter image description here

4 Answers 4

20

Please add some more code so we can point the exact cause of the error, but given that description, seems like you're including an image somewhere in any of your pages, and the src of that image is being set dynamically after getting some information from the server, something like

<img [src]="imageUrl">

where imageUrl is a property from the component code.

The problem is that this imageUrl is null when Angular tries to load the page, so the source of the image is null (that's why you get the 404 when trying to get an image from http:localhost:8100/null; that ending null is because that property is null when the image element is being created in the view).

You could prevent that error by adding an additional check, like

<img *ngIf="imageUrl" [src]="imageUrl">

so the image will only be added if the source is ready.

Sign up to request clarification or add additional context in comments.

3 Comments

Thank you, this was annoying me for quite some time.
Thanks, this solves my problem as well! It works also even if src is loaded async
this is also occurred in ionic4 and solved my problem in ionic4. thanks
2

Add this & it will solve your query <img *ngIf="imageUrl" [src]="imageUrl">

Comments

0
<img [src]="imageUrl || 'assets/images/defaultimage.png' ">

1 Comment

Please add more details to support your post.
0

I am using ionic 4 angular <img *ngIf="imageUrl" src="{{imageUrl}}"> is works for fine for me.

3 Comments

Please don't make "me too" answers. Plus, you missed []
This the same answer as stackoverflow.com/a/51513057/5468463 but incorectly used src, should be [src] or {{imageUrl}}
Thank you.for correcting me. Yeah it will be <img *ngIf="imageUrl" src="{{imageUrl}}">

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.