title: I can't inject MAT_DIALOG_DATA! Error: inject() must be called from an injection context
body: <p>I'm using MAT_DIALOG_DATA to pass data to my dialog, however, I get this error in my browser console. </p>
  
  <pre><code>Uncaught Error: inject() must be called from an injection context
      at injectInjectorOnly (core.js:1767)
      at inject (core.js:1778)
      ...
      ...
      ...
  </code></pre>
  
  <p>First of all, I have to point out that I'm using angular 7.</p>
  
  <p>I watch many videos and read many articles that show that what I included in my project is enough:
  - I imported MAT_DIALOG_DATA from angular material.
  - I used dialog reference. 
  - I define my injection in the constructor.</p>
  
  <p>here the component.ts codes:</p>
  
  <pre class="lang-js prettyprint-override"><code>import { Component, OnInit, inject } from '@angular/core';
  import { MatDialogRef, MAT_DIALOG_DATA} from '@angular/material';
  
  @Component({
    selector: 'app-table-editor-dialog',
    templateUrl: './table-editor-dialog.component.html',
    styleUrls: ['./table-editor-dialog.component.scss']
  })
  export class TableEditorDialogComponent implements OnInit {
  
    constructor(
      @inject(MAT_DIALOG_DATA) public data: any,
      public matDialogRef: MatDialogRef&lt;TableEditorDialogComponent&gt;
     ) { }
  
    ngOnInit() {
    }
  
    getMessageId(id : Number){
    }
  }
  
  </code></pre>
  
  <p>I'm expecting to pass data to the dialog.
  What's is going on right now. My program Compiles successfully but inside the browser, the program stops working and show the error from the error.</p>
  
  <pre><code>Uncaught Error: inject() must be called from an injection context
      at injectInjectorOnly (core.js:1767)
  </code></pre>