title: Usage of [mat-dialog-close]
body: <p>I am a bit confused about the usage of [mat-dialog-close].</p>
  
  <p>So, I have a dialog with a form. If the user clicks the submit button, the form is validated. If the input is valid, the dialog is closed and the form is submitted. However, if the input is invalid, the dialog remains opened and an error message is shown. For that I want to use [mat-dialog-close] as it is described in the <a href="https://material.angular.io/components/dialog/overview#dialog-content" rel="noreferrer">official documentation</a> where it is used as follows:</p>
  
  <pre><code>&lt;button mat-button [mat-dialog-close]="true"&gt;Yes&lt;/button&gt;
  </code></pre>
  
  <p>I thought that I can just pass it a boolean and whether the tag is active depends on the boolean value of the variable. However, this does not work. I tried it like this:</p>
  
  <pre><code>&lt;button type="submit" (click)="addUser()" [mat-dialog-close]="formisvalid" mat-button&gt;Submit&lt;/button&gt;
  </code></pre>
  
  <p>I passed it the variable <code>formisvalid</code>. It's value is <code>true</code> unless the input is invalid. But now the dialog closes always, regardless of the value of <code>formisvalid</code>.
  I also tried replacing it with <code>false</code>. I thought the dialog would remain opened no matter what happens, but it would also always close.</p>
  
  <p>So, my question is: am I mistaken about the use of [mat-dialog-close] or am I just doing something wrong? If this is not achievable with the [mat-dialog-close] directive, what would be another way to achieve what I'm trying to do?</p>