Skip to content

Commit

Permalink
docs(upgrade): Add missing providers for downgrading a service
Browse files Browse the repository at this point in the history
  • Loading branch information
bertyhell committed Sep 25, 2017
1 parent 0f5c70d commit e59eb37
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Hero } from '../hero';

@Component({
selector: 'hero-detail',
providers: [HeroesService],
template: `
<h2>{{hero.id}}: {{hero.name}}</h2>
`
Expand Down
11 changes: 10 additions & 1 deletion aio/content/guide/upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -778,13 +778,22 @@ 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="l-sub-section">

Note that the 'heroes' string inside the factory refers to the AngularJS `HeroesService`.
It is common in AngularJS apps to chose a service name for the token (e.g. heroes)
and append the Service suffix to create the class name (e.g. heroesService)

</div>

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

<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 it's class as a type annotation:
You can then inject it in Angular by adding the service to the component providers
and using it's class as a type annotation in the component constructor:

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

Expand Down

0 comments on commit e59eb37

Please sign in to comment.