Q. How do you create a service singleton throughout the entire Angular application?

  • (A) Provide it in root injector using providedIn: 'root'
  • (B) Declare it in component providers
  • (C) Use @Singleton decorator
  • (D) Declare it in NgModule's declarations
πŸ’¬ Discuss
βœ… Correct Answer: (A) Provide it in root injector using providedIn: 'root'
Explanation: This makes the service singleton and available app-wide.
Explanation by: Mr. Dubey
This makes the service singleton and available app-wide.

πŸ’¬ Discussion


πŸ“Š Question Analytics

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