title: Angular NullInjectorError: No Provider for MatDialog
body: <p>so when I try to load my angular app, i get this error:</p>
  
  <pre><code>ERROR Error: Uncaught (in promise): 
  NullInjectorError: StaticInjectorError(AppModule)[AppComponent -&gt; MatDialog]:    
  StaticInjectorError(Platform: core)[AppComponent -&gt; MatDialog]:
  </code></pre>
  
  <p>my ts file looks like this, every other help question said to add MatDialog to my NgModule imports, but I have done that and am still receiving the error. Most of those errors were StaticInjectorErrors and mine is a NullInjectorError but I am not sure what the difference is between those two.</p>
  
  <pre class="lang-js prettyprint-override"><code>import { Component, NgModule } from '@angular/core';
  import { MatDialog, MatDialogConfig, MatDialogModule, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
  import { compileNgModule } from '@angular/compiler';
  import { AppDialog } from '../appDialog/app-dialog.component';
  
  @Component({
    selector: 'app-component',
    templateUrl: './app.component.html'
  })
  @NgModule({
    imports: [MatDialog, MatDialogRef, MatDialogConfig, MatDialogModule]
  })
  export class AppComponent {
  
  
    constructor(private appService: AppService, private dialog: MatDialog) {
    }
  
    openDialog() {
  
      const dialogConfig = new MatDialogConfig();
      dialogConfig.disableClose = true;
      dialogConfig.height = "350px";
      dialogConfig.width = "600px";
      dialogConfig.data = {
      };
  
      const dialogRef = this.dialog.open(AppDialog, dialogConfig);
      dialogRef.afterClosed().subscribe(result =&gt; {
        console.log('closed dialog');
        this.success = result;
      })
    }
  }
  </code></pre>