Q. How do you declare a service so it's available application-wide?

  • (A) Use @Injectable({ providedIn: 'root' })
  • (B) Add it to component's providers
  • (C) Use global keyword
  • (D) Declare in main.ts
πŸ’¬ Discuss
βœ… Correct Answer: (A) Use @Injectable({ providedIn: 'root' })
Explanation: This ensures the service is a singleton and available app-wide.
Explanation by: Mr. Dubey
This ensures the service is a singleton and available app-wide.

πŸ’¬ Discussion


πŸ“Š Question Analytics

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