“NullInjectorError: No provider for Overlay!” in console (Angular Material)

前端 未结 2 902
独厮守ぢ
独厮守ぢ 2021-01-24 22:09

I\'m getting an error when using Angular Material. Specifically,

ERROR Error: Uncaught (in promise): Error:
StaticInjectorError(AppModule)[CdkConnectedOverlay -&         


        
2条回答
  •  旧时难觅i
    2021-01-24 22:29

    I was getting the exact same error, due to lazy loaded modules which had the mat-menu component in them.

    What removed the error for me, was including MatDialogModule and MatMenuModule in the AppModule, which isn't lazy-loaded:

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

    Then the error was gone, and the mat-menu worked again

提交回复
热议问题