When using Dependency Injection in Angular, what is the significance of the @Injectable() decorator?
- It creates a new instance of the service
- It handles routing in Angular
- It injects a service into a component
- It marks a service as singleton
The @Injectable() decorator is used to mark a service as a singleton, meaning that Angular will create a single instance of the service and share it across components that request it.
Loading...
Related Quiz
- You are implementing a multi-step form where the user can navigate between different sections before submitting the entire form. How would you manage and validate the data of this form using Angular?
- How can you navigate to a different route using Angular's router?
- What is the purpose of the inject() function in Angular testing?
- How does Angular's router load a lazily-loaded module?
- Custom validators in Angular are functions that return an object of type ____ when the validation fails.