我有一个"对象"角色,该角色具有我从mongodb恢复的属性。数组a:
persona.faceDetection.photo=[255,216,255,224,0,16,74,70,73,70,0,1,1,1,0,1....etc]
var encodedData = window.btoa(persona.faceDetection.photo);
persona.faceDetection.photo=encodedData;
,然后我用角度表示:
<img data-ng-src="data:image/jpeg;base64,{{newPersona.faceDetection.photo}}" /img>
,但不要什么都没有显示。有什么简单的方法吗?PD:对我的英语和我的代码,对不起,我对此非常noob。
发布为答案
<image src data:image/jpeg;base64
要求base64如暗示。
因此persona.faceDetection.photo
对象必须为base64。
尝试
之类的东西 var myUint8 = new Uint8Array(persona.faceDetection.photo)
var myBase64 = window.btoa(String.fromCharCode.apply(null, myUint8));
persona.faceDetection.photo=myBase64 ;