相关疑难解决方法(0)

将图像转换为 Angular 中的字节数组(打字稿)

我有一个要求,需要将所选图像(表单组的一部分)转换为字节数组,该数组需要作为发布请求的一部分发送到后端。

HTML 组件:

<div class="form-group">
                <label>Image</label>
                <input type="file" accept="image/*" class="form-control" formControlName="productImage" onchange="displaySelectedImageFunc(this);">
                <img *ngIf="displaySelectedImage" src="{{selectedImageUrl}}">
                <span class="error-message" *ngIf="itemRegistrationForm.controls.productImage.dirty && itemRegistrationForm.controls.productImage.errors">Select Image of the product</span>
</div>
Run Code Online (Sandbox Code Playgroud)

typescript angular angular-forms

2
推荐指数
1
解决办法
2万
查看次数

如何在Angular2中将字节数组转换为图像

我从 api 获取字节数组,并且在我的 HTML 页面上应用了图像标签 <img src="data:{{model.asd_logo_type}};base64,{{model.dfgh_logo}}" alt="...">

但我无法显示图像。

请建议我能做什么。

angular2-forms angular2-routing angular

1
推荐指数
1
解决办法
4709
查看次数