Angular: writing configurable modules

Michele Stieven
6 min readFeb 21, 2018

Hi folks! It’s been some time since my last article, I promise I’ll be more active! :)

Actually I’ve been pretty busy reviewing projects and helping devs structuring their apps, and what I saw most of the times is this: Angular gives you lots of features out of the box, which is why you probably chose it, but it appears that most devs are not taking full advantage of them. The features I’m talking about are Dependency Injection and Observables, but in this article I’ll be focusing only on Dependency Injection.

DI is not just an ‘add-on’ of the framework, it’s a built-in mechanism which powers Angular’s most useful features and there’s nothing that prevents you from exploring every single possibility it offers!

If we had to give DI a description, it is a pattern which lets you inject services (classes) into components without creating them manually and passing them through a constructor. Who provides the right services? Angular of course! And the mechanism is dictated by the way you compose your modules, I wrote an article about that.

That’s cool! But take a breath and think: what is a dependency?

A dependency is something needed by something else in order to work properly. Most of the times a dependency is a service, but it could be something else. In fact, a component can have…

--

--

Responses (20)