In nativescript(with angular) is there any way to set the src of an image from the response of a web api call that returns the image as byte array/base64? There is not to much documentation, and I need to see the html and .ts files from a simple example, I have no code to paste here now.
1 Answer
you need to first create ImageSource form base64 string and then assign that imageSource to Image Native Element.
let imageSource = new ImageSource();
let loadedSource64 = imageSource.loadFromBase64(BASE_64_STRING_FROM_API_CALL);
if (loadedSource64 ) {
let image= <Image>this.imageElement.nativeElement;
image.imageSource = this.imageSource;
}
2 Comments
Madalin Sisu
loadedSource64 is true, and it seems that the imageSource has a value (width and height are correct), but nothing happens on the screen, the image is not shownMadalin Sisu
update: it was my fault, the
imageElement in my case was not the right object