How can I inject ViewContainerRef into a service?

后端 未结 2 892
走了就别回头了
走了就别回头了 2021-01-18 16:42

I\'m attempting to inject ViewContainerRef into a service, but am receiving error No provider for ViewContainerRef!. I found this PR, which address

2条回答
  •  情话喂你
    2021-01-18 17:09

    Services are meant to be completely agnostic to any view. If you are trying to have a service associated with a particular view, then you should add it to the providers list within a specific parent component/directive and pass the ViewContainerRef as an argument into one of the service's methods.

提交回复
热议问题