typescript - Primeng - 对话服务将数据传递给对话组件
问题描述
使用 PrimeNg 的动态对话示例展示了目标对话如何获取数据并显示。我可以通过创建一个带有可观察对象的服务来将数据传递给对话,但我知道对话服务有一些可用的参数(如数据)可以传递。对话将如何检索通过服务传递的数据?
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() {}
}
推荐阅读
- sql - 外键关系总和并处理空值
- apache-kafka - 卡夫卡:选举新领导人的基于群体的方法?
- javascript - slideToggle()jquery期间的异常填充/边距
- python - 以原始句子中出现的顺序提取所有匹配的子字符串
- javascript - 使用 javascript 和 python flask webserver 抓取实时数据时的性能问题
- python - 通过 django 中的中间件重新路由请求
- java - 在swagger上测试PUT操作,得到PreparedStatementCallback;糟糕的 SQL 语法
- php - 提交用户 ID 并显示用户名?
- python - Python Tkinter。修复使用绑定创建新窗口时出现的属性错误“Event object has no attribute tk”
- excel - 条件 IF() 语句问题,未返回所需值