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

140 阅读1分钟

“message”: "Can’t resolve all parameters for AppComponent in c:/Code/SPA/mystore/src/app/app.component.ts

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

解决办法

在app module里定义一个abstract class:

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

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

要获取更多Jerry的原创文章,请关注公众号"汪子熙":