23 lines
534 B
TypeScript
23 lines
534 B
TypeScript
// #docregion
|
|
import { Component, EventEmitter, Input, Output } from '@angular/core';
|
|
|
|
@Component({
|
|
selector: 'my-voter',
|
|
template: `
|
|
<h4>{{name}}</h4>
|
|
<button (click)="vote(true)" [disabled]="voted">Agree</button>
|
|
<button (click)="vote(false)" [disabled]="voted">Disagree</button>
|
|
`
|
|
})
|
|
export class VoterComponent {
|
|
@Input() name: string;
|
|
@Output() onVoted = new EventEmitter<boolean>();
|
|
voted = false;
|
|
|
|
vote(agreed: boolean) {
|
|
this.onVoted.emit(agreed);
|
|
this.voted = true;
|
|
}
|
|
}
|
|
// #enddocregion
|