Angular material StaticInjectorError: No provider for MatDialog

Sometimes the following error also come when you want to hit API and at that time you need to check whether the api is right or wrong, check spaces as well when you set API.

Uncaught (in promise): Error: StaticInjectorError(AppModule)[LoginDialogComponent -> InjectionToken MatDialogData]:


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.