Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit 15f413c

Browse files
committed
change upgraded providers to use annotation injection
1 parent 4a5965b commit 15f413c

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

public/docs/_examples/upgrade-module/ts/app/1-to-2-providers/app.module.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { HeroesService } from './heroes.service';
1414
UpgradeModule
1515
],
1616
providers: [{
17-
provide: 'heroes',
17+
provide: HeroesService,
1818
useFactory: (i: any) => i.get('heroes'),
1919
deps: ['$injector']
2020
}],

public/docs/_examples/upgrade-module/ts/app/1-to-2-providers/hero-detail.component.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// #docregion
2-
import { Component, Inject } from '@angular/core';
2+
import { Component } from '@angular/core';
33
import { HeroesService } from './heroes.service';
44
import { Hero } from '../hero';
55

@@ -11,7 +11,7 @@ import { Hero } from '../hero';
1111
})
1212
export class HeroDetailComponent {
1313
hero: Hero;
14-
constructor(@Inject('heroes') heroes: HeroesService) {
14+
constructor(heroes: HeroesService) {
1515
this.hero = heroes.get()[0];
1616
}
1717
}

public/docs/ts/latest/guide/upgrade.jade

+3-4
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,7 @@ table
269269
* We can make Angular 1 services available for injection to Angular 2 code
270270
by *upgrading* them. The same singleton instance of each service is shared
271271
between the frameworks. In Angular 2 these services will always be in the
272-
*root injector* and available to all components. They will always have
273-
*string tokens* - the same tokens that they have in Angular 1.
272+
*root injector* and available to all components.
274273
* We can also make Angular 2 services available for injection to Angular 1 code
275274
by *downgrading* them. Only services from the Angular 2 root injector can
276275
be downgraded. Again, the same singleton instances are shared between the frameworks.
@@ -731,12 +730,12 @@ figure
731730

732731
:marked
733732
We can upgrade the service using a Angular 2 [Factory provider](./dependency-injection.html#factory-providers)
734-
that requests the service from the Angular 1 `$injector`. The name of the Angular 2 dependency is up to you:
733+
that requests the service from the Angular 1 `$injector`:
735734

736735
+makeExample('upgrade-module/ts/app/1-to-2-providers/app.module.ts', 'register', 'app.module.ts')
737736

738737
:marked
739-
We can then inject it in Angular 2 using a string token:
738+
We can then inject it in Angular 2 using it's class as a type annotation:
740739

741740
+makeExample('upgrade-module/ts/app/1-to-2-providers/hero-detail.component.ts', null, 'hero-detail.component.ts')
742741

0 commit comments

Comments
 (0)