Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
778 views
in Technique[技术] by (71.8m points)

angular - Ionic2 - Displaying project images on the UI

I have the following brand new project, created with:

$ ionic start MyIonic2Project sidemenu --v2

enter image description here

My question is very simple:

  • where do I locate a directory for application images (asset images / fixed images / icons / etc)?, inside: {resources, src, www, etc}?. I'm looking for best practices.

  • how the url of these images would look like?. I wanna specify the <img src="<url/to/image.jpg>" /> element within the file: src/pages/home/home.ts.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

src/assets/ folder should contain all the resources. You can use any sub-folder depending on type of resource. During the build process everything in the src/assets is copied to www/assets.

how the url of these images would look like?

You have to give the path relative to your current file when it would be in www folder. It is generally ../assets/../filename if you are setting in your scss file.(This would end up as part of main.css within build folder). and ./assets/../filename in your html file.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...