Q. How do you make a service available application-wide?

  • (A) Provide it in root using `providedIn: 'root'`
  • (B) Provide it in every component
  • (C) Use global flag in angular.json
  • (D) Add it to index.html
πŸ’¬ Discuss
βœ… Correct Answer: (A) Provide it in root using `providedIn: 'root'`
Explanation: `providedIn: 'root'` makes a service singleton and available throughout the app.
Explanation by: Mr. Dubey
`providedIn: 'root'` makes a service singleton and available throughout the app.

πŸ’¬ Discussion


πŸ“Š Question Analytics

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