user3869304
user3869304

Reputation: 873

How to access files from assets folder in angular 2?

I have some images and style sheets files inside assets folder in angular 2 app but how to access those files and images in main index.html file?

Upvotes: 46

Views: 94820

Answers (3)

Rafael Medeiros
Rafael Medeiros

Reputation: 1283

It's one step behind /app. So if you are inside app/components/page/page.css, reference url(/assets/images/logo.png)

Upvotes: -3

Swapnil Thube
Swapnil Thube

Reputation: 103

Directly refer assets folder and inside images working

 <img src="/assets/img_avatar.png" />

Upvotes: 4

marioaviles
marioaviles

Reputation: 924

You have to put your files and use the relative path from the assets folder.

For example if i put a css file in src/assets/css/myfile.css, then I have to access it like this :

<link rel="stylesheet" href="assets/css/myfile.css">

Upvotes: 80

Related Questions