title: Angular 6 MatDialog cancel close event
body: <p>I have two components: <code>CustomerComponent</code> and <code>CustomerCreateUpdateComponent</code>.</p>
  
  <p><code>CustomerComponent</code> includes data table of customers.
  <code>CustomerCreateUpdateComponent</code> is a form with input controls for create/update.</p>
  
  <p>I have <code>mat-dialog</code> with <code>CustomerCreateUpdateComponent</code> in it.
  After opening the dialog and filling the form, I click submit button and <code>this.dialogRef.close(customer);</code> is executed. <code>customer</code> object has all values.</p>
  
  <p>In <code>CustomerComponent</code> I've <code>subscribe</code> on <code>this.dialog.open(CustomerCreateUpdateComponent).beforeClose().subscribe((customer: Customer) =&gt; { ... });</code></p>
  
  <p>It's <code>beforeClose()</code> method, so until the dialog is closed, I get back <code>customer</code> object back and POST it to api.</p>
  
  <p>If POST is successful everything is OK, the dialog is closed and data table updated.</p>
  
  <p>BUT, if POST did not succeed, api will return an error, which I want to show to the user and <strong>KEEP THE DIALOG OPEN</strong>, something like <code>if(error) { closeEvent.cancel() }</code></p>
  
  <p>I've seen the whole documentation for <code>mat-dialog</code>, nothing helpful. I'm almost sure there is not way to do it.</p>
  
  <p>Maybe someone had the same issue? Will be glad to hear any workaround.</p>