The Anubhav portal was launched in March 2015 at the behest of the Hon'ble Prime Minister for retiring government officials to leave a record of their experiences while in Govt service .
In Angular, a service is a reusable class used to
share data, logic, or functionality across components. It helps keep components
clean, lightweight, and focused on the UI.
What is a Service in Angular?
An Angular service is:
A TypeScript class
Used to handle business logic
Used for data access (API calls)
Used for state sharing between components
Independent of UI
Services are typically injected into components using Dependency Injection (DI).
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
What is a Service in Angular?
An Angular service is:
Why do we need Services?
Without services:
With services:
Simple Service Example
Create a service
This creates:
Service code
@Injectable()explainedprovidedIn: 'root'→ service is singleton (one instance for the whole app)Using Service in a Component
Real-world Example: API Call Service
Component usage
Service Scope (Where it lives)
1. App-level (Singleton)
One instance for entire app
2. Module-level
One instance per module
3. Component-level
New instance per component
Common Uses of Services
Services and Dependency Injection
Angular automatically:
Service vs Component
Best Practices
providedIn: 'root'unless scope is neededSummary