title: MatDialog dialog from Angular Material is not closing
body: <p>I am working on Angular 6 Application where I am using Angular material dialog box.
  I am trying to close the dialog box on success after the data is sent successfully to the server.
  I used</p>
  <pre><code>this.dialogRef.close(0);
  </code></pre>
  <p>or</p>
  <pre><code>this.dialogRef.close(0); 
  </code></pre>
  <p>or</p>
  <pre><code>this.dialogRef.close(); 
  </code></pre>
  <p>but it is still not working.</p>
  <p><strong>component1.ts</strong></p>
  <pre><code>let NewRegDialog = this.dialog.open(NewRegistrationComponent, {
  
    width: '750px',
    height: '500px',
    //disableClose: true,
    data: {
      email : email,
      regType : regType,
    },
  });
  
  NewRegDialog.afterClosed().subscribe(result =&gt; {
  
    if(result == 1){
      this.dialogRef.close('signup');
    }else{
      alert('Login failed') ;
      });
  </code></pre>
  <p><strong>component2.ts</strong></p>
  <pre><code>    import { Component, OnInit , Inject } from '@angular/core';
      import {  MatDialog  , MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';
  
      
     ... .. 
     .. .. 
      
        constructor( private restapi: ServicesService , private dialog: MatDialog ,   public dialogRef: MatDialogRef&lt;NewRegistrationComponent&gt;,
          @Inject(MAT_DIALOG_DATA) public data: any ) {
      
     ...
     ..... 
     }
      
      
       user_signup(data) {
      
      
            let userData = {Email: this.email };
            this.restapi.signupUsingSocial(userData).then(
              result =&gt; {
                this.responseData = result;
      
                if (this.responseData.status == 1) {
                  localStorage.setItem('token', this.responseData.data);
                  this.dialogRef.close(1);
      
                } else {
                  alert('give proper input');
                }
              },
              err =&gt; {
                this.dialogRef.close(0);
              }
            );}}
      
  </code></pre>