Angular DI: New Recommendation for inject() in the Angular Style Guide (2025)

Опубликовано: 02 Июнь 2026
на канале: Igor Sedov
4,159
209

Angular DI has a new recommendation in the Angular coding style guide: prefer the inject() function over constructor dependency injection. This shift is partly due to how native class fields behave in modern JavaScript. The inject() function also improves code readability and type inference.

Constructor injection is still fully supported. This is a style recommendation, not a breaking change.

In this video, I explain the recommendation in detail using high-quality visual explanations. You’ll also learn why constructor injection may trigger the "[ERROR] TS2729: Property is used before its initialization. [plugin angular-compiler]" error when targeting ES2022+. I also show how to fix this issue using inject().

Thanks to the ‪@Angular‬ Team for the valuable work.

ℹ️ Sources:
▪️https://github.com/angular/angular/di...
▪️https://next.angular.dev/style-guide

☕️ Donation:   / igorsedov  

Follow me on:
▪️Twitter:   / theigorsedov  
▪️LinkedIn:   / igorsedov  
▪️Bluesky: https://bsky.app/profile/igorsedov.com
▪️Instagram:   / theigorsedov  

Website: https://igorsedov.com
Email: [email protected]

#angular #angularframework