38 lines
968 B
TypeScript
Raw Normal View History

// #docregion
2016-11-12 15:27:51 +00:00
// #docregion hero-detail-io
export const heroDetail = {
bindings: {
hero: '<',
deleted: '&'
},
template: `
<h2>{{$ctrl.hero.name}} details!</h2>
<div><label>id: </label>{{$ctrl.hero.id}}</div>
<button ng-click="$ctrl.onDelete()">Delete</button>
`,
controller: function() {
this.onDelete = () => {
this.deleted(this.hero);
};
}
};
2016-11-12 15:27:51 +00:00
// #enddocregion hero-detail-io
2016-11-10 12:04:19 +00:00
2016-11-12 15:27:51 +00:00
// #docregion hero-detail-io-upgrade
2016-11-10 12:04:19 +00:00
import { Directive, ElementRef, Injector, Input, Output, EventEmitter } from '@angular/core';
import { UpgradeComponent } from '@angular/upgrade/static';
import { Hero } from '../hero';
@Directive({
selector: 'hero-detail'
})
export class HeroDetailDirective extends UpgradeComponent {
2016-11-10 12:04:19 +00:00
@Input() hero: Hero;
@Output() deleted: EventEmitter<Hero>;
constructor(elementRef: ElementRef, injector: Injector) {
super('heroDetail', elementRef, injector);
}
}
2016-11-12 15:27:51 +00:00
// #enddocregion hero-detail-io-upgrade