我正在使用 PrimeNG 14 和 Angular 14。我想打開一個與下載影像的確切大小相同的對話框,但不太確定如何動態調整對話框的大小。目前我有
<p-dialog [(visible)]="showDialog" [style]="{width: '450px'}" header="My Image" [modal]="true"
styleClass="p-fluid">
<img
id="myImage"
[src]="myImage" />
</p-dialog>
我在其中下載我的影像使用
this.myService.getFile(this.myId).subscribe({
next: (response) => {
const blob = new Blob([response], { type: response.type });
this.imageSize = this.formatBytes(blob.size);
const objectURL = URL.createObjectURL(blob);
this.myImage = this.sanitizer.bypassSecurityTrustUrl(objectURL);
this.showDialog = true;
},
error: (error: Error) => {
console.log(error);
console.error("image download error occurred.");
}
});
有沒有辦法動態確定我的影像大小,然后打開對話框到這些尺寸?
uj5u.com熱心網友回復:
從對話框組件中洗掉固定寬度后,它將適合其中的內容。
這是演示(stackblitz)。
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/531395.html
