Я использую средство выбора изображений, чтобы выбрать изображение и сохранить его в базе данных.Я хочу показать изображение в формате HTML, как я могу показать изображение в формате HTML?
pickImageFromGallery() {
this.imagePicker.getPictures({ maximumImagesCount: 1, outputType: 1 }).then((res) => {
if (res) {
if (res.length > 0) {
debugger;
this.helper.load();
const image = `data:image/jpeg;base64,${res}`;
let id=Date.now();
const pictures = this.storage.ref('deal/' + id);
pictures.putString(image, 'data_url').then(r => {
r.ref.getDownloadURL().then(r => {
this.deal = r
this.helper.dismiss();
this.helper.toast('Uploaded');
});
}, err => {
this.helper.dismiss();
console.log(err);
});
} else {
this.helper.toast('you didnt selected any image from the gallary');
this.helper.dismiss();
}
} else {
this.helper.toast('you didnt selected any image from the gallary');
this.helper.dismiss();
}
//this.user.photo='data:image/jpeg;base64,'+res;
}, (err) => {
console.log('failed to get images from gallery');
});
}
Как и в коде, URL для сохранения сохраняется в this.deal.Я тоже пытаюсь показать вот так
<ion-img (click)="setImage()" style="width:120px;height:120px" [src]="deal || 'https://cdn.dribbble.com/users/21845/screenshots/3938419/placeholder.png'" height="120px"></ion-img>