Patrice Chalin 05864c2584 docs(dependency-injection): revised Dart and TS code and prose (#1573)
docs(dependency-injection): revise Dart and TS code and prose
2016-06-03 11:16:46 -07:00

37 lines
920 B
TypeScript

// #docregion
// #docregion imports
import { Component } from '@angular/core';
import { CarComponent } from './car/car.component';
import { HeroesComponent } from './heroes/heroes.component.1';
import { provide, Inject } from '@angular/core';
import { APP_CONFIG, AppConfig,
HERO_DI_CONFIG } from './app.config';
import { Logger } from './logger.service';
// #enddocregion imports
@Component({
selector: 'my-app',
template: `
<h1>{{title}}</h1>
<my-car></my-car>
<my-heroes></my-heroes>
`,
directives:[CarComponent, HeroesComponent],
providers: [
Logger,
// #docregion providers
provide(APP_CONFIG, {useValue: HERO_DI_CONFIG})
// #enddocregion providers
]
})
export class AppComponent {
title:string;
// #docregion ctor
constructor(@Inject(APP_CONFIG) config:AppConfig) {
this.title = config.title;
}
// #enddocregion ctor
}