大佬教程收集整理的这篇文章主要介绍了angular – 将输入值传递给Dialog Component,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我想为所有确认类型的消息创建一个通用对话框,开发人员可以根据业务需求将文本输入到对话框中.但根据@L_696_2@,没有这样的规定.我们是否有相同的解决方法,或者我应该将其作为github上的功能请求发布?
export class ConfirmationDialogComponent implements OnInit { @input() confirmationtext: String; @input() confirmationtitle: String; @input() confirmationActions: [String,String][] = []; constructor(public dialogRef: mddialogRef<ConfirmationDialogComponent>) { } ngOnInit() { } }
这样打电话:
let dialogRef = this.dialog.open(ConfirmationDialogComponent);
openDialog() { let dialogRef = this.dialog.open(DialogoverviewExampleDialog); let instance = dialogRef.componenTinstance; instance.text = "This text can be used inside DialogoverviewExampleDialog template "; console.log('dialogRef',dialogRef); }
然后显然在DialogoverviewExampleDialog模板中你可以做到:
this is the text {{text }}
我通常会做什么,我会创建一个我的Component理解的配置对象,然后在打开模态时我会传递它:
private config = { title :"Hello there ",text :"what else ? " }; openDialog() { let dialogRef = this.dialog.open(DialogoverviewExampleDialog); let instance = dialogRef.componenTinstance; instance.config = this.config; console.log('dialogRef',dialogRef); }
然后在模态组件内:
<div class="my-modal"> <h1>{{Config.titlE}}</h1> <p>{{Config.text}}</p> </div>
以上是大佬教程为你收集整理的angular – 将输入值传递给Dialog Component全部内容,希望文章能够帮你解决angular – 将输入值传递给Dialog Component所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。