Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular material StaticInjectorError: No provider for MatDialog

I am getting below error in my browser console when I launch my Angular 5 page in browser.

ERROR Error: StaticInjectorError(AppModule)[AppComponent -> MatDialog]: StaticInjectorError(Platform: core)[AppComponent -> MatDialog]: NullInjectorError: No provider for MatDialog! at _NullInjector.webpackJsonp.../../../core/esm5/core.js._NullInjector.get

What am I missing?

like image 905
Vishwajit R. Shinde Avatar asked Feb 23 '18 12:02

Vishwajit R. Shinde


1 Answers

This error usually occurs when the service you are trying to use has not been provided in your @NgModule.

To use the MatDialog service, you will need to go to your module file and add MatDialogModule to the array of imports:

import {MatDialogModule} from '@angular/material/dialog';

@NgModule({
  imports: [MatDialogModule]
})
export class MyModule {}

You can find the import along with more information on how to use the dialog here: https://material.angular.io/components/dialog/api.

like image 112
vince Avatar answered Oct 22 '22 11:10

vince