Which decorator is used to inject a service into an Angular component?
- @Injectable()
- @Component()
- @Service()
- @InjectService()
To inject a service into an Angular component, you use the @Injectable() decorator. This decorator is applied to the service class, allowing Angular's dependency injection system to recognize and provide the service when requested by a component. The other options (@Component(), @Service(), @InjectService()) are not used for this purpose.
Loading...
Related Quiz
- When creating a shared service that should retain state and be available for all components, the service should be provided in _____.
- To update the value of a specific FormControl without emitting an event or re-evaluating the validation status, you would use the ______ method with specific configuration.
- If you want to serve your Angular application on a specific port other than the default (4200), which command should you use?
- An application form has a section that should only become available if the user selects a specific option in a dropdown menu. Which Angular feature would you use to conditionally display this section?
- In the context of NgRx, when an action is dispatched, it is processed by a ________ to produce a new state.