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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.