Angular no provider for NameService

后端 未结 18 1887
遇见更好的自我
遇见更好的自我 2020-11-30 18:44

I\'ve got a problem loading a class into an Angular component. I\'ve been trying to solve it for a long time; I\'ve even tried joining it all in a single file. What I have i

18条回答
  •  攒了一身酷
    2020-11-30 19:38

    In Angular you are able to register a service in two ways:

    1. Register a service in module or root component

    Effects:

    • Available into all components
    • Available on lifetime application

    You should take care if you register a service into a lazy loaded module:

    • The service is available only into components declared into that module

    • The service will be available on lifetime application only when the module is loaded

    2. Register a service into any other application component

    Effects:

    • Will be injected a separate instance of the Service into the component

    You should take care if you register a service into any other application component

    • The instance of the injected service will be available only into the component and all of its children.

    • The instance will be available on the component lifetime.

提交回复
热议问题