Showing posts with label Angular Services. Show all posts
Showing posts with label Angular Services. Show all posts
Saturday, August 15, 2020
Thursday, August 13, 2020
Angular Provider Scope
In the previous post, we saw on how to make a service
available globally by declaring the @Injectable providedIn: 'root'. We can
also declare module-level services using ProvidedIn, in this post we shall see
on how to declare module-level service using @Injectable
To limit the scope of a service to a module we need to specify the module in the providedIn instead of ‘root’. In the below code the HellpService is made available only to the HelloModule, the service is not available to any other Modules in the Application.
To limit the scope of a service to a module we need to specify the module in the providedIn instead of ‘root’. In the below code the HellpService is made available only to the HelloModule, the service is not available to any other Modules in the Application.
Labels:
Angular,
Angular Services,
Injectable,
providedIn,
Service Injection
Angular Service Scope
In Angular, Services are a great way to share information
among Components that don't know each other. Based on how we register a service
we can control the scope/visibility of the service across the Application.
Services can be registered with 3 levels of scope
1. Global Scope
2. Module Scope
3. Component Scope
Services can be registered with 3 levels of scope
1. Global Scope
2. Module Scope
3. Component Scope
Labels:
Angular,
Angular Services,
Injectable,
providedIn,
Service Injection
Wednesday, August 12, 2020
What are Angular Services?
In Angular, a Service is a class that is used to provide shared features across different components.
Components are the View layer they deal only with UI specific features.
Functional tasks like ajax calls, business logic, validations, logging, etc are
delegated to the services.
Services are a great way to share information among Components that don't know
each other. Based on how we register a service we can control the scope /
visibility of the service across the Application. Services can be registered
with 3 levels of scope
1. Global Scope
2. Module Scope
3. Component Scope
1. Global Scope
2. Module Scope
3. Component Scope
Subscribe to:
Posts (Atom)

