2015-12-31 08:46:32 +02:00
|
|
|
|
// #docregion
|
2016-05-03 14:06:32 +02:00
|
|
|
|
import { Component, EventEmitter, Input, Output } from '@angular/core';
|
2016-06-08 01:06:25 +02:00
|
|
|
|
import { Hero } from '../hero';
|
2015-12-31 08:46:32 +02:00
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'hero-detail',
|
|
|
|
|
template: `
|
|
|
|
|
<h2>{{hero.name}} details!</h2>
|
|
|
|
|
<div><label>id: </label>{{hero.id}}</div>
|
|
|
|
|
<button (click)="onDelete()">Delete</button>
|
|
|
|
|
`
|
|
|
|
|
})
|
|
|
|
|
export class HeroDetailComponent {
|
2016-06-08 01:06:25 +02:00
|
|
|
|
@Input() hero: Hero;
|
2015-12-31 08:46:32 +02:00
|
|
|
|
@Output() deleted = new EventEmitter<Hero>();
|
|
|
|
|
onDelete() {
|
|
|
|
|
this.deleted.emit(this.hero);
|
|
|
|
|
}
|
|
|
|
|
}
|