Simon Lüscher
Simon Lüscher

Reputation: 131

html img-tag: can't find Image in same folder

I'm trying to make a Slideshow for my WebApp with Angular 2. The problem is, when I try to display an image I get a 404-Error. Error-Message

enter image description here

The picture is in the same folder as my html-file.

<img *ngIf="i == activeIndex" src="try1.png" style="width:100%; height: 500px">

PS: The *ngIf isn't the problem it perfectly works with an internet source.

Upvotes: 0

Views: 2626

Answers (2)

Ali Adravi
Ali Adravi

Reputation: 22723

Simply keep your images in assets folder and use path as

src="/assets/try1.png"

Hope it will help you

Upvotes: 1

Andriy
Andriy

Reputation: 15442

try to add it to your .angular-cli.json file under assets section:

"assets": [
  "assets",
  "favicon.ico",
  "try1.png"
]

and make sure your image file is located in src/ directory

Upvotes: 0

Related Questions