angular - 如何在角度 2 中为我的模态弹出窗口设置宽度和高度
问题描述
我正在尝试为我的模态设置高度和宽度。我该怎么做?
方式1:
<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>
解决方案
添加 Input 属性绑定以向对话框添加动态宽度
<app-dialog [height]="200" [width]="200" [(visible)]="showDialog">
<h1>Hello World</h1>
<button (click)="showDialog = !showDialog" class="btn">Close</button>
</app-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>
推荐阅读
- python-3.x - 数据透视表顺序
- javascript - MongoDB查找与数组的完全匹配
- spring-cloud-stream - spring-cloud-stream-binder-kafka-streams - 在功能实现中读取 Avro 消息
- python - 在多个处理器上执行时挂起的示例代码
- python-3.x - 添加与另一个数据框比较的 NaN 值
- python - Python Boolean:为什么在评估值和变量中类和类实例之间存在差异?
- python - 我可以在类声明中使用重载运算符吗?
- java - 无法在 Eclipse 控制台上打印结果
- java - 尝试使用 javac 编译 java 源代码:包 R 不存在
- ios - 在 MessageKit 中点击时放大图像视图 - Swift