No injector for custom defined data type的解决办法

“message”: "Can’t resolve all parameters for AppComponent in c:/Code/SPA/mystore/src/app/app.component.ts
No injector for custom defined data type的解决办法

‘DebugConfig’ only refers to a type, but is being used as a value here.

解决办法

在app module里定义一个abstract class:

No injector for custom defined data type的解决办法

在NgModule的providers里定义这个injectable objects:

No injector for custom defined data type的解决办法

此时在Component里就可以注入DebugConfig了:

No injector for custom defined data type的解决办法

要获取更多Jerry的原创文章,请关注公众号"汪子熙":
No injector for custom defined data type的解决办法

相关文章:

  • 2021-12-03
  • 2022-12-23
  • 2021-08-04
  • 2022-12-23
  • 2021-09-12
  • 2021-12-28
  • 2021-04-28
  • 2021-11-18
猜你喜欢
  • 2022-12-23
  • 2021-12-15
  • 2021-05-13
  • 2021-04-10
  • 2021-09-16
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案