[英]primeng resuable p-dialog component
In my angular application I want to create a primeng p-dialog component which can be re-used across different component.在我的 angular 应用程序中,我想创建一个可以在不同组件中重复使用的primeng p-dialog 组件。 Following is my implementation, but the p-dialog component is not displayed as a popup(as a dialog), it displays below the parent component.
以下是我的实现,但 p-dialog 组件不显示为弹出窗口(作为对话框),它显示在父组件下方。
log-component.html日志组件.html
<app-primeng-dialog
[isvisible]="showDialog">
</app-primeng-dialog>
log-component.ts日志组件.ts
showDialogWindow()
{
this.showDialog = true;
}
DialogComponent.ts对话框组件.ts
export class DialogComponent implements OnInit {
@Input isvisible;
ngOnInit() {
}
}
DialogComponent.html DialogComponent.html
<div>
<div *ngIf="isvisible">
<div class="col-md-12 text-center p-1">
<p-dialog [(visible)]="isvisible" [modal]="true" [responsive]="true"
[style]="{width: '250px', minWidth: '100px', height:'350px', 'text-align': 'center'}" [minY]="70"
[maximizable]="false" [baseZIndex]="10000" [closeOnEscape]="true" [closable]="false" position="top">
<button type="button" pButton label="Ok" class="ui-button"></button>
<button type="button" pButton label="Cancel" class="ui-button"></button>
</p-dialog>
</div>
</div>
</div>
I don't know why you are facing that kind of problem, but I have working example where your code works fine.我不知道您为什么会遇到这种问题,但是我有一个工作示例,您的代码可以正常工作。 Please check the link of stackblitz below=>
请检查下面stackblitz的链接=>
Stackblitz Demo Link . Stackblitz 演示链接。
Note: Do not set showDialog
to false in DialogComponent
.注意:不要在
DialogComponent
中将showDialog
设置为 false。 If you do that then pop up Modal will display once and then will not display again.如果你这样做,那么弹出的 Modal 将显示一次,然后不会再次显示。 That is why I have used
@Output() deleteSelf = new EventEmitter<any>();
这就是为什么我使用
@Output() deleteSelf = new EventEmitter<any>();
in the code.在代码中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.