title: Angular2 material dialog self close
body: <p>I used angular2 material <code>MdDialog</code> to show a form.</p>
  
  <p>When user submits the form, a request is sent to the backend and if the request is successful, I need to close the dialog. If backend request failed, I need to keep the dialog open.</p>
  
  <p>I can close the dialog by using a button like below.</p>
  
  <pre><code>&lt;button md-raised-button md-dialog-close&gt;Cancel&lt;/button&gt;
  </code></pre>
  
  <p>But, in this case, I only need to close the dialog only if the backend request is successful, so I need a way to programmatically close the dialog.</p>
  
  <p>The component which is shown inside the dialog doesn't have the dialog ref, and I don't know any other way to self close the dialog from the component.</p>
  
  <p>Is there any way I an close the dialog from within the component inside the dialog?</p>