πŸ“Š Angular
Q. How can services be shared across all modules in Angular?
  • (A) Add them in any component
  • (B) Provide them in a child component
  • (C) Provide them in root injector using providedIn: 'root'
  • (D) Declare them in component metadata
πŸ’¬ Discuss
βœ… Correct Answer: (C) Provide them in root injector using providedIn: 'root'

Explanation: Services with `providedIn: 'root'` are singleton and shared across the app.

Explanation by: Mr. Dubey
Services with `providedIn: 'root'` are singleton and shared across the app.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
49
Total Visits
πŸ“½οΈ
10 mo ago
Published
πŸŽ–οΈ
Mr. Dubey
Publisher
πŸ“ˆ
82%
Success Rate