1

i´ll try to load an image after the page is loaded into a modal form that opens on click.

My image Tag looks like this:

<img src="/src/files/bstand{{detailEntry.bearbeitungsstand}}.png">

The image source is correct. But when i load the page my variable detailentry is empty because i am fill it on click of a button. so the console shows me a 404 error with url: "/src/files/bstand.png" which does not exist Wehen ic Click the button the image is loaded properly.

I remember that i used ng_src in angular 1 and the equivalent shout be [src] i thought but it does not work.

Thank you for any answer!

1
  • did u try [src]="'/src/files/bstand' + detailEntry.bearbeitungsstand + '.png'" ? Commented Jul 7, 2017 at 14:04

2 Answers 2

1

You can wait for the detailEntry with ngIf

<img *ngIf="detailEntry.bearbeitungsstand" src="/src/files/bstand{{detailEntry.bearbeitungsstand}}.png">
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks that was the answer!
1

You could use *ngIf to keep the image tag from being rendered without a valid src.

<img *ngIf="detailEntry.bearbeitungsstand" src="/src/files/bstand{{detailEntry.bearbeitungsstand}}.png">

1 Comment

Thanks that was the answer!

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.