Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: fix bug in code examples for downgrading a service #19371

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 11 additions & 2 deletions aio/content/guide/upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -778,16 +778,25 @@ delete them once the upgrade is over.
It's also recommended to export the `heroesServiceFactory` function so that Ahead-of-Time
compilation can pick it up.

<div class="alert is-helpful">

**Note:** The 'heroes' string inside the factory refers to the AngularJS `HeroesService`.
It is common in AngularJS apps to choose a service name for the token, for example "heroes",
and append the "Service" suffix to create the class name.

</div>

<code-example path="upgrade-module/src/app/ajs-to-a-providers/ajs-upgraded-providers.ts" title="ajs-upgraded-providers.ts">
</code-example>

You can then provide the service to Angular by adding it to the `@NgModule`:

<code-example path="upgrade-module/src/app/ajs-to-a-providers/app.module.ts" region="register" title="app.module.ts">
</code-example>

You can then inject it in Angular using its class as a type annotation:
Then use the service inside your component by injecting it in the component constructor using its class as a type annotation:

<code-example path="upgrade-module/src/app/ajs-to-a-providers/hero-detail.component.ts" title="hero-detail.component.ts">

</code-example>

<div class="alert is-helpful">
Expand Down