R

Ram Sharma • 3.40K Points
Extraordinary

Q. Which Angular feature is used to create a singleton service?

  • (A) Using @Component decorator
  • (B) Providing service in component providers
  • (C) Providing service in @Injectable with 'providedIn: root'
  • (D) Using @NgModule declarations
  • Correct Answer - Option(C)
  • Views: 18
  • Filed under category Angular JS
  • Hashtags:

Explanation by: Ram Sharma
Using `providedIn: 'root'` in @Injectable makes the service singleton throughout the app.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.