Hmm, it seems you *don't* need to update a module to tell Angular that that module will use a particular service.

The @Injectable() decorator with its providedIn flag does this.

...which isn't obvious, and is the wisdom being imparted in every tutorial I have read so far. Even one written specifically for 11!

Am I missing something?

The official tutorial goes:

providers: [
// no need to place any providers due to the `providedIn` flag...

So that's the final word then?

I'm guessing this changed at some point, and either

1. those tutorials are outdated, or,
2. the people writing it for Angular 11 did not keep up?


But there's also this section:

which clearly goes: "By configuring providers, you can make services available to the parts of your application that need them."

And now I'm more confused -- this goes over my head. 🙃

...and this section gives a bit more perspective. Looks like providers might be an advanced topic...?

But at least, it seems, you can see it's just one of three ways to provide a service. But in some situations, a service can be "provided" using *something else* other than Angular's service class... and I don't know when you'd do that, and how.

Sign in to participate in the conversation

Fosstodon is an English speaking Mastodon instance that is open to anyone who is interested in technology; particularly free & open source software.