parent
9333db68e2
commit
632d0d8d93
|
@ -157,7 +157,7 @@ include ../../../../_includes/_util-fns
|
||||||
We don't have a gigantic factory class to maintain.
|
We don't have a gigantic factory class to maintain.
|
||||||
Both `Car` and consumer simply ask for what they need and the `Injector` delivers.
|
Both `Car` and consumer simply ask for what they need and the `Injector` delivers.
|
||||||
|
|
||||||
This is what a **Dependency InjectionFramework** is all about.
|
This is what a **Dependency Injection Framework** is all about.
|
||||||
|
|
||||||
Now that we know what Dependency Injection is and appreciate its benefits,
|
Now that we know what Dependency Injection is and appreciate its benefits,
|
||||||
let's see how it is implemented in Angular.
|
let's see how it is implemented in Angular.
|
||||||
|
@ -175,7 +175,7 @@ include ../../../../_includes/_util-fns
|
||||||
We'll begin with a simplified version of the `HeroesComponent`
|
We'll begin with a simplified version of the `HeroesComponent`
|
||||||
that we built in the [The Tour of Heroes](../tutorial/).
|
that we built in the [The Tour of Heroes](../tutorial/).
|
||||||
```
|
```
|
||||||
import {Component} from 'angular2/angular2';
|
import {Component} from 'angular2/core';
|
||||||
import {Hero} from './hero';
|
import {Hero} from './hero';
|
||||||
import {HEROES} from './mock-heroes';
|
import {HEROES} from './mock-heroes';
|
||||||
|
|
||||||
|
@ -381,13 +381,13 @@ include ../../../../_includes/_util-fns
|
||||||
|
|
||||||
When we wrote ...
|
When we wrote ...
|
||||||
```
|
```
|
||||||
import {bootstrap} from 'angular2/angular2';
|
import {bootstrap} from 'angular2/platform/browser';
|
||||||
|
|
||||||
bootstrap(AppComponent, [HeroService]);
|
bootstrap(AppComponent, [HeroService]);
|
||||||
```
|
```
|
||||||
... Angular translated that statement into a mapping instruction involving the Angular `provide` method
|
... Angular translated that statement into a mapping instruction involving the Angular `provide` method
|
||||||
```
|
```
|
||||||
import {bootstrap, provide} from 'angular2/angular2';
|
import {bootstrap, provide} from 'angular2/platform/browser';
|
||||||
|
|
||||||
bootstrap(AppComponent, [
|
bootstrap(AppComponent, [
|
||||||
provide(HeroService, {useClass:HeroService})
|
provide(HeroService, {useClass:HeroService})
|
||||||
|
@ -533,7 +533,7 @@ include ../../../../_includes/_util-fns
|
||||||
That's not going to work. There is no type called `config` and we didn't register the `config` object under that name anyway.
|
That's not going to work. There is no type called `config` and we didn't register the `config` object under that name anyway.
|
||||||
We'll need a little help from another Angular decorator called `@Inject`.
|
We'll need a little help from another Angular decorator called `@Inject`.
|
||||||
```
|
```
|
||||||
import {Inject} from 'angular2/angulare2'
|
import {Inject} from 'angular2/core'
|
||||||
|
|
||||||
constructor(heroService: HeroService, @Inject('app.config') config)
|
constructor(heroService: HeroService, @Inject('app.config') config)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue