← Back to Article List         
Angular Services - Interview Questions

Angular Services - Interview Questions

Published on 02 Oct 2026     3 min read Angular
Angular Services - Interview Questions

Angular Services & Dependency Injection — Interview Quick Revision

1. What is a service in Angular?

An Angular service is a reusable class used for shared logic such as API calls, authentication, state, and business logic.
export class ProductService { }

2. Why do we need Angular services?

Services help separate business/data logic from components and allow functionality to be reused across multiple components.
Example: ProductService can handle all product-related API calls.

3. What is Dependency Injection in Angular?

Dependency Injection (DI) is a design pattern where Angular automatically provides required dependencies instead of classes creating them manually.
constructor(private productService: ProductService) { }

4. How does Angular's DI system work?

Angular registers dependencies using providers, stores/manages them through injectors, and injects them where requested.
Component → requests service → Injector → provides service instance.

5. What is @Injectable()?

@Injectable() marks a class as available for Angular's dependency injection system and allows it to have dependencies injected.
@Injectable({ providedIn: 'root' })

6. What does providedIn: 'root' mean?

providedIn: 'root' registers the service with the application's root injector, normally creating one shared instance for the application.
@Injectable({ providedIn: 'root' })

7. What is a provider?

A provider tells Angular's DI system how to create or obtain a dependency.
providers: [ProductService]

8. What is an injector?

An injector is Angular's DI mechanism that maintains providers, creates service instances, and supplies dependencies when requested.

9. What is hierarchical Dependency Injection?

Angular has a hierarchy of injectors. It searches from the current injector upward until it finds a matching provider, allowing dependencies to have different scopes.

10. What is the difference between root-level and component-level services?

Root-level: normally one shared instance across the application.
Component-level: a separate instance is created for that component and its descendant injector scope.

11. What is the inject() function?

inject() is a modern Angular API for obtaining a dependency from the current injection context without constructor parameters.
private productService = inject(ProductService);

12. Constructor injection vs inject() — what is the difference?

Constructor injection: dependency is passed through the class constructor. inject() retrieves it directly from Angular's injection context.
constructor(private service: ProductService) {} vs service = inject(ProductService);

13. How do you share data between components using a service?

Create a shared root service and store shared state using Signals, RxJS Observable/BehaviorSubject, etc. Components inject the same service instance to access or update the data.
user = signal<User | null>(null);

14. What happens when a service is provided at the component level?

Angular creates a component-scoped service instance rather than using the root instance for that injector branch.
@Component({ providers: [ProductService] }) → component and its descendants share that scoped instance.