跳到正文
本页尚未翻译成中文,以下为英文原文。 查看英文版

No Provider Found ​

You see this error when you try to inject a service but have not declared a corresponding provider. A provider is a mapping that supplies a value that you can inject into the constructor of a class in your application.

Read more on providers in our Dependency Injection guide.

Debugging the error ​

Work backwards from the object where the error states that a provider is missing: No provider for <token> found. This is commonly thrown in services, which require non-existing providers.

To fix the error ensure that your service is registered in the list of providers of an NgModule or has the @Service decorator at top.

The most common solution is to add a provider in @Service

ts
@Service()

基于 MIT 许可证发布。