A focused reference for Angular's dependency injection system that covers both modern patterns like the inject() function and traditional constructor injection. You get practical examples for common scenarios like hierarchical injectors, InjectionTokens, and factory providers, plus the decorators you need to know like @Optional and @SkipSelf. The guidance is clearly oriented toward Angular 21's functional approach while still covering the older patterns you'll encounter in existing codebases. If you're constantly looking up the syntax for multi providers or can't remember how forwardRef works, this consolidates the essentials. The examples are concise and ready to adapt, which beats scanning through official docs when you just need to wire up a service correctly.

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

Install

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

Installs into .claude/skills of the current project.

Files

Angular Dependency Injection

Version: Angular 21 (2025) Tags: DI, Services, Providers, Tokens, inject()

References: DI Guide • API • inject()

API Changes

This section documents recent version-specific API changes.

  • NEW: Functional injection with inject() — Preferred over constructor injection in modern Angular source

  • NEW: inject() with Optional decorator — inject(Service, { optional: true })

  • NEW: inject() with SkipSelf — inject(Service, { skipSelf: true })

  • NEW: Tree-shakable InjectionToken — new InjectionToken<T>(desc, { providedIn: 'root' })

Best Practices

  • Use providedIn: 'root' for singleton services
@Injectable({ providedIn: 'root' })
export class LoggerService {
  log(message: string) { console.log(message); }
}
  • Use inject() function for cleaner code
@Component({})
export class MyComponent {
  private service = inject(MyService);
  private router = inject(Router);
}

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
1sickn33 avatarhtml-injection-testingsickn33/antigravity-awesome-skillshtml injection testing174skills.sh installs
2longbridge avatargenerate-component-documentationlongbridge/gpui-componentGenerate documentation for new components. Use when writing docs, documenting components, or creating component documentation.172skills.sh installs
3oguzhan18 avatarangular-control-flowoguzhan18/angular-ecosystem-skillsALWAYS use when working with Angular Control Flow syntax, @if, @for, @switch, @defer, or new template syntax in Angular applications.170skills.sh installs
4oguzhan18 avatarangular-zonelessoguzhan18/angular-ecosystem-skillsALWAYS use when working with Angular Zoneless, zoneless change detection, provideZonelessChangeDetection, or removing zone.js in Angular applications.170skills.sh installs
5charleswiltgen avataraxiom-ui-recordingcharleswiltgen/axiomUse when setting up UI test recording in Xcode 26, enhancing recorded tests for stability, or configuring test plans for multi-configuration replay. Based on WW169skills.sh installs
6oguzhan18 avatarangular-signals-httpoguzhan18/angular-ecosystem-skillsALWAYS use when working with Angular Signals and HttpClient, toSignal, toObservable, or HTTP with signals.169skills.sh installs