πŸ“Š Angular
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
πŸ’¬ Discuss
βœ… Correct Answer: (A) Add @Injectable({ providedIn: 'root' })

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

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

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
51
Total Visits
πŸ“½οΈ
1 y ago
Published
πŸŽ–οΈ
Mr. Dubey
Publisher
πŸ“ˆ
97%
Success Rate