title: NullInjectorError: No provider for MatDialog - trying to create a wrapper service for MatDialog
body: <p>I am new to coding and new to Angular so I thought I would ask for some help. This is my first question so please be patient with me.</p>
  <p>I want to create a wrapper service for the Angular Material Dialog Service (I'm just trying to teach myself - this isn't for a production app) so I made a service in my app like so:</p>
  <pre class="lang-js prettyprint-override"><code>import {Injectable} from '@angular/core';
  import {MatDialog} from '@angular/material';
      
  @Injectable({
      providedIn: 'root'
  })
  export class MatDialogWrapperService {
      
      constructor(private dialog: MatDialog) {
      }
      
      open(componentRef, config = {}) {
          this.dialog.open(componentRef, config);
      }
  }
  </code></pre>
  <p>Now I try to add this to another angular component in my app like so: I import it, add it to the providers array, put it in the constructor and then place it in a method (I have removed some of the code for ease of reading)</p>
  <pre class="lang-js prettyprint-override"><code>@Component({
      selector: 'app-intro-form',
      templateUrl: './intro-form.component.html',
      providers: [MatDialogWrapperService],
          styleUrls: ['./intro-form.component.scss']
  })
  export class IntroFormComponent {  
    
      constructor(private modalService: MatDialogWrapperService ) {
      }
      
      modalCall() {
          this.modalService.open(ModalFormComponent, {width: '500px'});
      }
  }
  </code></pre>
  <p>When I load my app I see the following error in the console:</p>
  <blockquote>
  <p>Unhandled Promise rejection: StaticInjectorError(AppModule)[
  MatDialogWrapperService -&gt; MatDialog]:  StaticInjectorError(Platform:
  core)[ MatDialogWrapperService -&gt; MatDialog]:</p>
  <p>NullInjectorError: No provider for MatDialog! ; Zone:  ; Task:
  Promise.then ; Value: Error: StaticInjectorError(AppModule)[
  MatDialogWrapperService -&gt; MatDialog]:  StaticInjectorError(Platform:
  core)[ MatDialogWrapperService -&gt; MatDialog]:</p>
  </blockquote>
  <p>I thought I had injected the MatDialog correctly in my wrapper service? What am I doing wrong?</p>
  <p>Thanks in advance.</p>