angular/aio/content/examples/component-interaction/src/app/voter.component.ts
dario-piotrowicz 0d19be1996 refactor(docs-infra): add types to all the aio examples buttons (#44557)
add types to all the buttons in the angular.io examples to encourage
the best practice of always including a type per button (regardless
to whether it is in a form or now)

PR Close #44557
2022-02-03 12:44:47 -08:00

22 lines
564 B
TypeScript

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