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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With