How can you ensure that a service provides a single, shared instance across an entire Angular application?
- Using a local provider in a component
- Using providedIn property
- Using the @Injectable() decorator
- Using the @Singleton() decorator
To ensure a service provides a single, shared instance across an entire Angular application, you can use the providedIn property in the @Injectable decorator and specify a module where the service should be provided. This ensures a singleton instance.
Loading...
Related Quiz
- When testing an Angular service, why might you use a spy?
- In NgRx, the _____ property of an action usually contains additional information or context.
- Which RxJS operator is used to transform the items emitted by an Observable?
- In Angular, the _____ pipe is used to automatically subscribe and unsubscribe from an Observable.
- How do you create a custom pipe in Angular?