angular-cn/public/docs/_examples/cb-ts-to-js/js-es6/app/hero-di-inject.component.es6

33 lines
684 B
Plaintext
Raw Normal View History

import { Component, Inject, NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
// #docregion
class HeroComponent {
constructor(name) {
this.name = name;
}
}
HeroComponent.annotations = [
new Component({
selector: 'hero-di-inject',
template: `<h1>Hero: {{name}}</h1>`
})
];
HeroComponent.parameters = [
[new Inject('heroName')]
];
// #enddocregion
export class HeroesDIInjectModule { }
HeroesDIInjectModule.annotations = [
new NgModule({
imports: [ BrowserModule ],
providers: [ { provide: 'heroName', useValue: 'Windstorm' } ],
declarations: [ HeroComponent ],
bootstrap: [ HeroComponent ]
})
];