M

Mr. Dubey • 100.28K Points
Coach

Q. How do you declare a service to be injectable throughout the app?

  • (A) Add @Injectable({ providedIn: 'root' })
  • (B) Declare it in app.module.ts providers array only
  • (C) Declare it in every component providers array
  • (D) Use @Component decorator
  • Correct Answer - Option(A)
  • Views: 13
  • Filed under category Angular

Explanation by: Mr. Dubey
This registers the service with the root injector for app-wide singleton.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.


Question analytics