DEV Community

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

Posted on • Edited on • Originally published at Medium

6 3

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

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...

SurveyJS custom survey software

JavaScript UI Libraries for Surveys and Forms

SurveyJS lets you build a JSON-based form management system that integrates with any backend, giving you full control over your data and no user limits. Includes support for custom question types, skip logic, integrated CCS editor, PDF export, real-time analytics & more.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay