Chapter 7: Angular Components and Providers: Classes, Factories & Values

by David Aden

In the Chapter 5, we looked at how to get data into and out of components using the @Input and @Output annotations. In this article, we’ll look at another fundamental aspect of Angular components — their ability to use providers.

You may have seen “providers” in a list of properties you can use to configure components, and you might have realized that they allow you to define a set of injectable objects that will be available to the component. That’s nice, but it of course begs the question, “what is a provider?”

Answering that question gets us into an involved discussion of Angular’s Dependency Injection (DI) system. We may specifically cover DI in a future ...

Get Learn Angular: Your First Week now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.