πŸ“Š Angular
Q. How do you define a service as a singleton in Angular?
  • (A) Provide it in the root injector
  • (B) Use the providedIn: 'any'
  • (C) Create a new instance in each component
  • (D) Use the Injectable() without providers
πŸ’¬ Discuss
βœ… Correct Answer: (A) Provide it in the root injector

Explanation: To make a service singleton, use `@Injectable({ providedIn: 'root' })`.

Explanation by: Mr. Dubey
To make a service singleton, use `@Injectable({ providedIn: 'root' })`.

πŸ’¬ Discussion


πŸ“Š Question Analytics

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