Images are kept in "assets" directory as its public but can it be kept in respective components so HTML files can easily access
-
It is not mandatory but you can access the image from assets folders too. – Sreemat Sep 11 '17 at 07:11
2 Answers
It is not required to put images in assets project.
Asset folder is preconfigured. When you run build command then all the things in asset folder will copied to output folder(dist) automatically for publish. So no need to copy manually.
You can also configured different folder as a asset. see in below code sample.
"assets": [
"assets",
"xyz",
"favicon.ico"
],

- 551
- 4
- 17
-
Could you pls give me leads if I would like to access an image from an HTML kept within the same component: – Kaustubh Dutta Sep 11 '17 at 08:18
-
did you want to keep image in folder which component is placed ? – Dhaval kansagara Sep 11 '17 at 08:24
-
I would not like to place my image in assets but in specific components that I have created. – Kaustubh Dutta Sep 11 '17 at 10:21
-
@KaustubhDutta Did you find any solution? I want to copy my images in components too. – Sky Feb 08 '20 at 06:29
Assets folder is used in angular for maintaining file which doesn't have to be modified while compiling. You can't maintain any files like Images, json or any other file types in a component folder(folders are only for development purpose only) because it will be not recognized while compiling.
If you are in any component always set image path like this. Always maintain assets as a starting folder
"assets/pic.img"
Not like this and it won't be recognized
"./../assets/pic.img"

- 1,595
- 10
- 16