Shijith Mohanan
Shijith Mohanan

Reputation: 793

NullInjectorError: No provider for MatDialog getting while adding mat dialog

Am getting "NullInjectorError: No provider for MatDialog", below is the code

Open stackblitz link and click on orders link

https://stackblitz.com/edit/tms-prototype

enter image description here

Upvotes: 0

Views: 5722

Answers (1)

yurzui
yurzui

Reputation: 214017

You should import MatDialog from the same place where you have imported MatDialogModule since they represent different bundles.

So use:

import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
                                                                           ^^^^^^^

instead of

import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';

because you imported MatDialogModule in SharedModule from @angular/material/dialog

Forked Stackblitz

Upvotes: 4

Related Questions