title: How to communicate from mat dialog component to the component where mat dialog is implemented?
body: <p>I have a dialog component and app component where the material dialog is implemented. 
  <strong>Here is the code of app component</strong></p>
  
  <pre><code>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&lt;DialogComponent&gt;;
    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();
  }
  }
  </code></pre>
  
  <p>The dialog component is where the form is implemented, I need to take the form value and receive it in here. I tried using angular input and output to achieve this but dint work coz there is no child and parent communication. <strong>Here is the Dialog component</strong></p>
  
  <pre><code>import { Component } from '@angular/core';
  
  @Component({
    template: `
      &lt;h1 mat-dialog-title&gt;Add Item&lt;/h1&gt;
      &lt;mat-dialog-content&gt;
      &lt;mat-form-field  class="example-full-width"&gt;
          &lt;input matInput placeholder="Item name here..."&gt;
      &lt;/mat-form-field&gt;
      &lt;/mat-dialog-content&gt;
      &lt;mat-dialog-actions&gt;
        &lt;button mat-button (click)="saveMessage()"&gt;Add&lt;/button&gt;
        &lt;button mat-button (click)="closeDialog()"&gt;Cancel&lt;/button&gt;
      &lt;/mat-dialog-actions&gt;
    `
  })
  export class DialogComponent {
    saveMessage() {
      console.log('how to send data to the app component');
    }
    closeDialog() {
      console.log('how to close');
    }
  }
  </code></pre>
  
  <p><strong><a href="https://stackblitz.com/edit/angular-rrzbgz?file=dialog.component.ts" rel="noreferrer">Working Example on StackBlitz</a></strong></p>