πŸ“Š Angular
Q. How do you prevent a service from being a singleton and provide a new instance at component level?
  • (A) Provide the service in the component's providers array
  • (B) Use providedIn: 'root' in @Injectable
  • (C) Provide the service in the AppModule providers
  • (D) Declare service as abstract
πŸ’¬ Discuss
βœ… Correct Answer: (A) Provide the service in the component's providers array

Explanation: Providing the service in component providers creates a new instance per component.

Explanation by: Mr. Dubey
Providing the service in component providers creates a new instance per component.

πŸ’¬ Discussion


πŸ“Š Question Analytics

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