Total Guide To Angular 6+ Dependency Injection — providedIn vs providers:[ ] 💉
Tomas Trajan 🇨🇭

Tomas Trajan 🇨🇭 @tomastrajan

About: 👋 I build, teach, write & speak about #Angular & #NgRx at angularexperts.io 🅰️ Google Developer Expert for Angular #GDE ❤️ ️ angularexperts.io 🛠️ polyrepo env tooling omniboard.dev

Location:
Zurich, Switzeland
Joined:
Oct 7, 2018

Total Guide To Angular 6+ Dependency Injection — providedIn vs providers:[ ] 💉

Publish Date: Nov 6 '18
15 0

I know, I know… Angular 7 is out already but this topic is as relevant as ever! Angular 6 brought us new better providedIn syntax for registration of services into Angular dependency injection mechanism.

As it turned out, this topic can evoke quite emotional responses and there is a lot of confusion across GitHub comments, Slack and Stack Overflow so let’s make this clear once and for all!

📖 What we’re going to learn

  1. Dependency Injection (DI) recapitulation (optional😉)
  2. The Old Way™ of doing DI in Angular  —  providers: []
  3. The New Way™ of doing DI in Angular  —  providedIn: 'root' | SomeModule
  4. Possible scenarios when using providedIn
  5. Recommendation on how to use new syntax in your projects
  6. Summary

Read more...

Comments 0 total

    Add comment