This covers Angular 21's modern service patterns with dependency injection, focusing on the inject() function over constructor injection and providedIn configurations. You'll use it whenever you're building services, managing shared state, or setting up DI providers. The examples show practical patterns like signal-based state management in services, factory providers, and lazy-loaded service configurations. It's noticeably aligned with Angular's newer functional style, which is good if you're working on current projects but might feel incomplete if you're maintaining older codebases that still use constructor injection everywhere.

skills.sh installs
193
GitHub stars
7
last updated
Aug 21, 2026

Install

$ npx -y skills add oguzhan18/angular-ecosystem-skills --skill angular-services --agent claude-code

Installs into .claude/skills of the current project.

Files

Angular Services

Version: Angular 21 (2025) Tags: Services, @Injectable, DI

References: Services Guide • @Injectable API

Best Practices

  • Create service with providedIn
@Injectable({ providedIn: 'root' })
export class DataService {
  getData() {
    return this.http.get('/api/data');
  }
}
  • Use inject() function
@Injectable({ providedIn: 'root' })
export class UserService {
  private http = inject(HttpClient);
  
  getUsers() {
    return this.http.get<User[]>('/api/users');
  }
}
  • Use factory providers
@Injectable({
  providedIn: 'root',
  useFactory: () => new LoggerService(environment.production)
})
export class LoggerService {
  constructor(private isProduction: boolean) {}
}
  • Use providedIn: 'any' for lazy services
@Injectable({ providedIn: 'any' })
export class LazyService {}
  • Use service in component
@Component({})
export class MyComponent {
  private dataService = inject(DataService);
  
  data$ = this.dataService.getData();
}
  • Use multiple services

Sponsors

Details

Repository
github.com/oguzhan18/angular-ecosystem-skills
Category
Frontend Development
First seen
Jun 3, 2026

More from oguzhan18/angular-ecosystem-skills

All 45
1allenai2014 avatarpencil-ui-designallenai2014/pencil-ui-design使用 Pencil MCP 创建工业级 UI 设计的完整工作流和组件库192skills.sh installs
2oguzhan18 avatarangular-performanceoguzhan18/angular-ecosystem-skillsALWAYS use when optimizing Angular applications for performance, change detection, bundle size, lazy loading, or runtime performance.192skills.sh installs
3nexu-io avatarhtml-ppt-pitch-decknexu-io/open-designInvestor-ready 10-slide HTML pitch deck — white + blue→purple gradient hero, big numbers, traction bar chart, $4.5M-style ask page. Use when the user wants a fu190skills.sh installs
4davila7 avataravalonia-layout-zafirodavila7/claude-code-templatesGuidelines for modern Avalonia UI layout using Zafiro.Avalonia, emphasizing shared styles, generic components, and avoiding XAML redundancy.188skills.sh installs
5charleswiltgen avataraxiom-swiftui-layout-refcharleswiltgen/axiomReference — Complete SwiftUI adaptive layout API guide covering ViewThatFits, AnyLayout, Layout protocol, onGeometryChange, GeometryReader, size classes, and iO187skills.sh installs
6oguzhan18 avatarangular-clioguzhan18/angular-ecosystem-skillsALWAYS use when working with Angular CLI, generating components, services, building applications, or workspace configuration in Angular projects.187skills.sh installs