angular-docs-cn/public/docs/_examples/cb-ts-to-js/js-es6/app/hero-di-inject-additional.component.es6
Filipe Silva 12eb19fa3c feat(cb-ts-to-js): add es6 examples
update docshredder to shred .es6
optimized focus gulp task
convert imports and metadate sections
add DI section
add host and query metadata section
add intro
fix capitalization and grammar
2016-11-11 19:44:17 -08:00

62 lines
1.1 KiB
JavaScript

import {
Attribute,
Component,
Inject,
Optional,
NgModule
} from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
// #docregion
class TitleComponent {
constructor(titlePrefix, title) {
this.titlePrefix = titlePrefix;
this.title = title;
this.msg = '';
}
ok() {
this.msg = 'OK!';
}
}
TitleComponent.annotations = [
new Component({
selector: 'hero-title',
template: `
<h1>{{titlePrefix}} {{title}}</h1>
<button (click)="ok()">OK</button>
<p>{{ msg }}</p>
`
})
];
TitleComponent.parameters = [
[new Optional(), new Inject('titlePrefix')],
[new Attribute('title')]
];
// #enddocregion
class AppComponent {
}
AppComponent.annotations = [
new Component({
selector: 'hero-di-inject-additional',
template: `<hero-title title="Tour of Heroes">
</hero-title>`
})
];
export class HeroesDIInjectAdditionalModule { }
HeroesDIInjectAdditionalModule.annotations = [
new NgModule({
imports: [ BrowserModule ],
declarations: [
AppComponent,
TitleComponent
],
bootstrap: [ AppComponent ]
})
];