A

Admin • 832.27K 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: 24
  • Filed under category Angular JS
  • Hashtags:

Explanation by: Admin

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.

Be the first to start discuss.