使用 PrimeNg 的动态对话示例展示了目标对话如何获取数据并显示。
我可以通过创建一个带有 observable 的服务来将数据传递给对话,但我知道对话服务有一些可用的参数(如数据)可以传递。
对话将如何检索通过服务传递的数据?
https://www.primefaces.org/primeng/#/dynamicdialog
https://github.com/primefaces/primeng/blob/master/src/app/components/dynamicdialog/dynamicdialog-config.ts
https://github.com/primefaces/primeng/blob/master/src/app/components/dynamicdialog/dialogservice.ts
最佳答案
父组件内部:
this.dynamicDialogRef = this.dialogService.open(EmployeeDialogComponent, {
header: 'View Employee Details for - ' + this.employee.name,
width: '90%',
contentStyle: {"min-height": "800px", "overflow": "auto"},
baseZIndex: 10000,
data: {employee: this.employee}
});
内部对话框组件:export class EmployeeDialogComponent implements OnInit {
constructor(public ref: DynamicDialogRef, public config: DynamicDialogConfig) {
console.log("Data: " + JSON.stringify(config.data.employee));
}
ngOnInit() {}
}
关于typescript - Primeng - 对话服务将数据传递给对话组件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54490357/