
Angular Di
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-codeInstalls 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- Angular Viewchild174
- Angular Cypress172
- Angular Router172
- Angular Control Flow170
- Angular Zoneless170
- Nx170
- Angular Signals Http169
- Angular Ssr168
- Angular Injector165
- Angular Query160
- Shadcn Ng152
- Angular Tailwind245
- Angular Material233
- Rxjs214
- Angular Security211
- Angular Bootstrap205
- Angular Cdk201
- Angular Testing197
- Ngrx195
- Angular Animations194
- Angular I18n194
- Angular Services193
- Angular Performance192
- Angular Jest190