mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
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
22 lines
564 B
TypeScript
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
|