22 lines
		
	
	
		
			529 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
		
		
			
		
	
	
			22 lines
		
	
	
		
			529 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
|  | // #docregion
 | ||
|  | import {Component, EventEmitter, Input, Output} from 'angular2/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
 |