πŸ“Š Angular
Q. How can you provide a service at the component level?
  • (A) Add the service in the component's providers array
  • (B) Add @Injectable({ providedIn: 'root' })
  • (C) Add the service in app.module providers
  • (D) Use @Component decorator
πŸ’¬ Discuss
βœ… Correct Answer: (A) Add the service in the component's providers array

Explanation: Providing service in component providers creates a new instance scoped to that component.

Explanation by: Mr. Dubey
Providing service in component providers creates a new instance scoped to that component.

πŸ’¬ Discussion


πŸ“Š Question Analytics

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