簡體   English   中英

如何在角度2中為模態彈出窗口設置寬度和高度

[英]How can I set width and height to my modal popup in angular 2

我試圖將高度和寬度設置為我的模態。 我該怎么做?

WAY1:

 <button (click)="showDialog = !showDialog" class="btn">Open</button>

  <app-dialog [(visible)]="showDialog" [height]="200" [width]="250">
<h1>Hello World</h1>
<button (click)="showDialog = !showDialog" class="btn">Close</button>
  </app-dialog>

添加輸入屬性綁定以將動態寬度添加到對話框

<app-dialog [height]="200" [width]="200"   [(visible)]="showDialog">
    <h1>Hello World</h1>
    <button (click)="showDialog = !showDialog" class="btn">Close</button>
</app-dialog>

dialog.html

<div [@dialog] *ngIf="visible" class="dialog" [ngStyle]="{width:width+'px',height:height+'px'}">

    <ng-content></ng-content>
    <button *ngIf="closable" (click)="close()" aria-label="Close" class="dialog__close-btn">X</button>
</div>
<div *ngIf="visible" class="overlay" (click)="close()"></div>

示例: https//stackblitz.com/edit/angular-rdjxwy

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM