Reputation: 99
I'm trying to move my project from silverlight to Angular5. I need to show image on the UI. I'm using the same service(in c#) which i used for silverlight and it returns a byte[] along with a bunch of data as a class object. How to convert it into a Bitmap Image or anything and how to bind this to the <img class="immg-up img-ht-sp-2" src="data:image/png;base64," onerror="this.src='./images/image df.png'" />
in html. I'm using typescript and also need to know the equivalent type of byte[] in c#.
Upvotes: 0
Views: 1368
Reputation: 8605
If you're going to to use a data URI for the image, then you need to either return Base64 text from your C# service, or convert it to Base64 in the Angular code.
Assuming this is done and stored in a property called imageData
, this should do it:
<img class="immg-up img-ht-sp-2" src="data:image/png;base64,{{imageData}}" onerror="this.src='./images/image df.png'" />
Upvotes: 2