2016-10-13 17:59:00 +01:00
|
|
|
import {
|
|
|
|
Component,
|
|
|
|
EventEmitter,
|
|
|
|
Input,
|
|
|
|
Output,
|
|
|
|
NgModule
|
|
|
|
} from '@angular/core';
|
|
|
|
import { BrowserModule } from '@angular/platform-browser';
|
|
|
|
|
|
|
|
// #docregion
|
|
|
|
class ConfirmComponent {
|
|
|
|
constructor(){
|
|
|
|
this.ok = new EventEmitter();
|
|
|
|
this.notOk = new EventEmitter();
|
|
|
|
}
|
|
|
|
onOkClick() {
|
|
|
|
this.ok.next(true);
|
|
|
|
}
|
|
|
|
onNotOkClick() {
|
|
|
|
this.notOk.next(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ConfirmComponent.annotations = [
|
|
|
|
new Component({
|
2016-11-11 19:44:00 -08:00
|
|
|
moduleId: module.id,
|
2016-10-13 17:59:00 +01:00
|
|
|
selector: 'my-confirm',
|
2016-11-11 19:44:00 -08:00
|
|
|
templateUrl: 'confirm.component.html',
|
2016-10-13 17:59:00 +01:00
|
|
|
inputs: [
|
|
|
|
'okMsg',
|
|
|
|
'notOkMsg: cancelMsg'
|
|
|
|
],
|
|
|
|
outputs: [
|
|
|
|
'ok',
|
|
|
|
'notOk: cancel'
|
|
|
|
]
|
|
|
|
})
|
|
|
|
];
|
|
|
|
// #enddocregion
|
|
|
|
|
|
|
|
class AppComponent {
|
|
|
|
constructor(){
|
|
|
|
}
|
|
|
|
onOk() {
|
|
|
|
this.okClicked = true;
|
|
|
|
}
|
|
|
|
onCancel() {
|
|
|
|
this.cancelClicked = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
AppComponent.annotations = [
|
|
|
|
new Component({
|
|
|
|
selector: 'hero-io',
|
|
|
|
template: `
|
|
|
|
<my-confirm [okMsg]="'OK'"
|
|
|
|
[cancelMsg]="'Cancel'"
|
|
|
|
(ok)="onOk()"
|
|
|
|
(cancel)="onCancel()">
|
|
|
|
</my-confirm>
|
|
|
|
<span *ngIf="okClicked">OK clicked</span>
|
|
|
|
<span *ngIf="cancelClicked">Cancel clicked</span>
|
|
|
|
`
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
export class HeroesIOModule { }
|
|
|
|
|
|
|
|
HeroesIOModule.annotations = [
|
|
|
|
new NgModule({
|
|
|
|
imports: [ BrowserModule ],
|
|
|
|
declarations: [
|
|
|
|
AppComponent,
|
|
|
|
ConfirmComponent
|
|
|
|
],
|
|
|
|
bootstrap: [ AppComponent ]
|
|
|
|
})
|
|
|
|
];
|