A

Admin • 832.27K Points
Coach

Q. How do you prevent a service from being a singleton and provide a new instance at component level?

  • (A) Provide the service in the component's providers array
  • (B) Use providedIn: 'root' in @Injectable
  • (C) Provide the service in the AppModule providers
  • (D) Declare service as abstract
  • Correct Answer - Option(A)
  • Views: 22
  • Filed under category Angular JS
  • Hashtags:

Explanation by: Admin

Providing the service in component providers creates a new instance per component.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.