title: Submit form from Angular Dialog Template
body: <p>I'm trying to submit form from dialog but  <code>form.value</code> is <code>null</code>. I dont know what is missing.. I provide some  code and <a href="https://stackblitz.com/edit/ang-material-dialog-watw58" rel="nofollow noreferrer">DEMO</a> as your reference.</p>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>&lt;div&gt;
  &lt;button mat-raised-button (click)="openDialog()"&gt;Pick one&lt;/button&gt;
  &lt;/div&gt;
  
    &lt;ng-template #callAPIDialog&gt;
          &lt;form #userForm="ngForm" (ngSubmit)="onSend(form.value)"&gt;
          &lt;h2 matDialogTitle&gt;Add Organization&lt;/h2&gt;
          &lt;mat-form-field&gt;
              &lt;input matInput [(ngModel)]="organisationName" placeholder="Your organization" [ngModelOptions]="{standalone: true}"&gt;
              &lt;input matInput [(ngModel)]="enabled" [(value)]="Y" [ngModelOptions]="{standalone: true}"&gt;
            &lt;/mat-form-field&gt;
          &lt;mat-dialog-actions align="end"&gt;
              &lt;button mat-button matDialogClose="no"&gt;Cancel&lt;/button&gt;
              &lt;button type="submit" mat-button matDialogClose="yes"&gt;Submit&lt;/button&gt;
          &lt;/mat-dialog-actions&gt;
      &lt;/form&gt;
      &lt;/ng-template&gt;
  </code></pre>
  
  <p><strong>COmponent</strong></p>
  
  <pre><code>openDialog() {
      let dialogRef = this.dialog.open(this.callAPIDialog);
      dialogRef.afterClosed().subscribe(result =&gt; {
          if (result !== undefined) {
              if (result !== 'no') {
                const enabled = "Y"
                  console.log(result);
              } else if (result === 'no') {
                 console.log('User clicked no.');
              }
          }
      })
  }
  
  
  onSend(form: NgForm){
    let data = form.value;
    console.log(data);
  }
  </code></pre>