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

前端 未结 2 932
独厮守ぢ
独厮守ぢ 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条回答
  •  庸人自扰
    2021-01-24 22:24

    You're using conflicting versions of Angular and Angular Material. (Your Angular dependencies are on version 6, while the Angular CDK & Angular Material dependencies are on version 7, which require Angular v7.)

    You should either:

    • Update all versions of Angular.

      This can be done by running ng update @angular/core which should update all Angular dependencies.

      (For more info about the update command, check out the docs, or the Update Angular website)

    • Downgrade your version of the Angular CDK and Angular Material.

      This can be achieved by running the following command:

      npm i @angular/{cdk,material}@'^6.0.0'
      

      This command should install version 6 of the CDK and Angular Material.

提交回复
热议问题