title: Angular Material Dialog return value
body: <p>I have a following dialog component (which I open using <code>dialog.open(MyDialogComponent)</code> in another component):</p>
  
  <pre><code>export class MyDialogComponent implements OnInit {
    constructor(public matDialogRef: MatDialogRef&lt;MyDialogComponent&gt;) {}
  
    ngOnInit() {}
  }
  </code></pre>
  
  <p>I know I can return any data to the calling component by executing <code>matDialogRef.close(dataToReturn)</code> bound to a button in dialog component. But how can I return the data if a user clicked elsewhere but the popup to close it?</p>