angular - 将 base64 图像数据数组显示为图像

标签 angular nativescript angular2-nativescript

我正在输出一个项目的 RadListView,每个项目都有一个 base64 格式的图像,但我无法显示它们。

在我的组件循环中

let base64ImageSource = new ImageSource;
base64ImageSource = fromBase64(returned_expenses[i].receipt_data);

在我的模板中

<Image row="0" col="1" [src]="base64ImageSource" horizontalAlignment="right" width="100" height="100"  stretch="none"></Image>

而且没有图像。

我看过下面的代码

this.imageSource = new ImageSource();
var loadedBase64 = this.imageSource.loadFromBase64(MY_BASE_64_STRING_PREVIOUSLY_SAVED);
console.log(loadedBase64);
if (loadedBase64) {
  let photo = <Image>this.photoImage.nativeElement;
  photo.imageSource = this.imageSource;
  this.photo = photo;
}

但是我不知道这条线是干什么的

let photo = <Image>this.photoImage.nativeElement;

即。 photoImage 被声明为什么?

感谢您的指导!

最佳答案

在您的示例代码中,photoImage 可能是对元素的引用,可能正在使用 ViewChild

HTML

....
<Image #photoImage></Image>
...

TS

@ViewChild("photoImage") photoImage: ElementRef;

关于angular - 将 base64 图像数据数组显示为图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54445828/

相关文章:

angular - 在 ngIf 执行后将焦点放在 ul li 上

javascript - Typescript - 动态从字典或数组中获取下一个和上一个项目

angular - System.import 来自 JavaScript 或者特定于 Angular 2

Angular 农业网格 : How to render HTML in cell?

css - NativeScript Playground - 未应用内置类

javascript - 在 NativeScript 中从 cocoapods 调用方法

Nativescript-iOS应用名称?

angular - 如何修复 'No componentRef found in DetachedRouteHandle'

ios - 未处理的 Promise 拒绝 : ImageSource. setNativeSource() 需要 UIImage 实例

angular - 将 Typescript 2 "noUnusedLocals"与 Angular2 或 NativeScript 结合使用