小编kar*_*rty的帖子

如何从Mat对话框组件与实现Mat对话框的组件进行通信?

我有一个对话框组件和应用程序组件,用于实现材质对话框。 这是应用程序组件的代码

import { Component } from '@angular/core';
import {VERSION, MatDialog, MatDialogRef} from '@angular/material';
import { DialogComponent } from '../dialog.component';

@Component({
  selector: 'my-app',
  templateUrl: './app.component.html',
  styleUrls: [ './app.component.css' ]
})
export class AppComponent  {
  name = 'Angular 5';
  DialogRef: MatDialogRef<DialogComponent>;
  constructor(private dialog: MatDialog) {}
  ngOnInit() {
  }
  addItem() {
    this.DialogRef = this.dialog.open(DialogComponent);
  }

receiveMessageFromDialogComponent() {
  // how to receive message from dialog component
}
closeDialog(): void {
  this.DialogRef.close();
}
}
Run Code Online (Sandbox Code Playgroud)

对话框组件是实现表单的地方,我需要获取表单值并在此处接收它。我尝试使用角度输入和输出来实现此目的,但是精巧的工作因为没有孩子和父母的交流。这是对话框组件

import { Component } from '@angular/core';

@Component({
  template: …
Run Code Online (Sandbox Code Playgroud)

angular-cli angular

5
推荐指数
2
解决办法
7030
查看次数

标签 统计

angular ×1

angular-cli ×1