As we learned in my previous article, we can now use the inject() function inside components, directives, and pipes. Here are the reasons I chose it over the constructor for dependency injection. The first thing I noticed is that it is cleaner and more readable:

Using constructor
Using inject()

Next…

--

--

--

--

Netanel Basal

Netanel Basal

A FrontEnd Tech Lead, blogger, and open source maintainer. The founder of ngneat, husband and father.