【问题标题】:Angular Dialog - access variable from child componentAngular Dialog - 从子组件访问变量
【发布时间】:2017-07-10 20:49:34
【问题描述】:

我有一个组件,它具有打开另一个组件的对话框的功能:

open() {
        this.dialogRef = this.dialog.open(ChildComponent);

        this.dialogRef.afterClosed().subscribe(result => {
            this.dialogRef = null;
        });
    }

从这个父组件,我想从 ChildComponent 访问一个变量。我怎样才能做到这一点?

【问题讨论】:

    标签: dialog parent-child angular-reactive-forms


    【解决方案1】:

    您可以使用 componentInstance 字段访问智利对话框组件的变量。 例如

    this.dialogRef.componentInstance.variableName

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-02-27
      • 1970-01-01
      • 2017-11-04
      • 1970-01-01
      • 2018-07-06
      • 1970-01-01
      • 2023-03-27
      • 1970-01-01
      相关资源
      最近更新 更多