Show Image with dinamically src

images

#1

Hi, i have to set an Image src with a value that i receive from a json file.
The value is ~/images/flags/name.png
I put this record on the Image tag in this way
< Image src=" ‘item.nomeBandiera’ " height=“24” width=“24” >< /Image >
If i try to print as a label text the item.nomeBandiera i can see the right string but i cant display the image.
In the console i receive this messae:
JS: Error in downloadBitmap - java.net.MalformedURLException: no protocol: ‘item.siglaBandiera’

Ho can i do this work?
Thank you


#2

Post your code so we can find something, from the error it just looks like it takes item.nomeBandiera as URL (plain string) instead of dynamic input?


#3

< StackLayout >
< Image src=item.siglaBandiera class=“action-image” height=“24” width=“24” >< /Image >
< Label [text]=‘item.nomeNave’ >< /Label >
< /StackLayout >


#4

So looking at your code I guess you are using Angular and src is assigned as string, you must use property binding to get value from item.siglaBandiera.


#5

Try this :


  <StackLayout>
    <Image [src]='item.siglaBandiera' class='action-image' height='24' width='24'>
    </Image>
    <Label [text]='item.nomeNave'></Label>
  </StackLayout>


#6

Thank to all!!
in this way work
< Image [src]=item.siglaBandiera.toString() class=“action-image” height=“24” width=“24” >< /Image >