0

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 1

1

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;
}
Sign up to request clarification or add additional context in comments.

2 Comments

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 shown
update: it was my fault, the imageElement in my case was not the right object

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.