gpt4 book ai didi

typescript - Primeng - 对话服务将数据传递给对话组件

转载 作者:行者123 更新时间:2023-12-04 12:19:44 28 4
gpt4 key购买 nike

使用 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/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com