Recall & Review
beginner
What is Dependency Injection (DI) in Angular?
Dependency Injection in Angular is a design pattern where Angular automatically provides components or services with the dependencies they need, instead of creating them manually.
Click to reveal answer
intermediate
How does Angular know which dependency to inject?
Angular uses tokens, usually class types, to look up and provide the correct dependency from its injector tree.Click to reveal answer
intermediate
What is an Angular injector?
An injector is a container that holds and manages the creation and lifetime of dependencies. Angular creates a tree of injectors to provide dependencies at different levels.
Click to reveal answer
beginner
What is the role of the @Injectable() decorator in Angular DI?
The @Injectable() decorator marks a class as available to be injected as a dependency and allows Angular to inject other dependencies into it if needed.Click to reveal answer
beginner
How can you provide a service at the root level in Angular?
You can provide a service at the root level by adding providedIn: 'root' in the @Injectable() decorator, making it a singleton available throughout the app.
Click to reveal answer
What does Angular use to decide which dependency to inject?
✗ Incorrect
Angular uses tokens, usually class types, to find and inject the correct dependency.
What decorator marks a class as injectable in Angular?
✗ Incorrect
The @Injectable decorator tells Angular that the class can be injected as a dependency.
Where is a service provided if you use providedIn: 'root'?
✗ Incorrect
providedIn: 'root' makes the service a singleton available throughout the entire app.
What is the Angular injector responsible for?
✗ Incorrect
The injector manages creating and providing dependencies to components and services.
How does Angular provide dependencies to a component?
✗ Incorrect
Angular injects dependencies by passing them as parameters in the component's constructor.
Explain how Angular's dependency injection system finds and provides a service to a component.
Think about how Angular uses the constructor and injector to supply dependencies.
You got /4 concepts.
Describe the purpose of the @Injectable() decorator in Angular dependency injection.
Consider what makes a class ready to be used as a service.
You got /4 concepts.