Swiftorial Logo
Home
Swift Lessons
AI Tools
Learn More
Career
Resources

Angular FAQ: Top Questions

32. What is a singleton service in Angular?

A singleton service is a service that is instantiated only once during the lifetime of an application. Angular provides singleton services via the root injector using providedIn: 'root'.


@Injectable({ providedIn: 'root' })
export class LoggerService {
  log(msg: string) { console.log(msg); }
}
        
  • This ensures the same instance is shared across all components and services.