The img src path in Ionic v1

im using ionic v1 and this is my folder structure.

www\tempaltes\acct\

      

in my acct folder , I have acct-home.html and patient_default.png

im trying to map my patient_default.png to acct-home using this code.

<img src="patient_default.png" alt="Test" width="100px" height="100px">

      

Please note that acct-home.html and patient_default.png are in the same folder. But it doesn't display correctly. Am I doing it wrong? Your help will be really appreciated.

Updated question:

this is my folder structure

root
   --API
      --patient_default.png
   --Www
      --templates
         --acct
           --acct-home.html

      

I tried to use

<img src="../../API/patient_default.png" alt="Test" width="100px" height="100px">

      

nothing is displayed.

Folder structure

+3


source to share


3 answers


With a type, src="patient_default.png"

you can only access if you are in the index or application initialization view ... But in your case, you need to access from subfolders. To do this, you need to provide the correct path to the src attribute, eg src="../your image containingfolder /logo.png"

. It's like going backwards.



And for your update you need to grow ../

to that folder, for example, suppose if "../your image containingfolder /logo.png"

points in your www folder, you need to add another one, for example "../../your image containingfolder /logo.png"

to use them, but make sure they are available in that location

+3


source


Don't use the templates folder as the absolute head of the path.

Use index.html instead, it will work!



index.html will use .html templates, but with Ionic the link will always be index.html.

+4


source


Create a folder in www\img

and then save patient_default.png

in that folder after that

try it

<img src="www/img/patient_default.png" alt="Test" width="100px" height="100px">

      

0


source







All Articles