<div>
<div class="board-row">
<square [value]="items[0]" (click) = 'getNum(items[0])'></square>
<square [value]="items[1]" (click) = 'getNum(items[1])'></square>
<square [value]="items[2]" (click) = 'getNum(items[2])'></square>
</div>
<div class="board-row">
<square [value]="items[3]" (click) = 'getNum(items[3])'></square>
<square [value]="items[4]" (click) = 'getNum(items[4])'></square>
<square [value]="items[5]" (click) = 'getNum(items[5])'></square>
</div>
<div class="board-row">
<square [value]="items[6]" (click) = 'getNum(items[6])'></square>
<square [value]="items[7]" (click) = 'getNum(items[7])'></square>
<square [value]="items[8]" (click) = 'getNum(items[8])'></square>
</div>
</div>
import{ Component,Input,OnInit,Output,OnChanges,EventEmitter,SimpleChanges } from '@angular/core';
@Component({
selector: 'broad',
templateUrl: './broad.component.html',
styleUrls: ['./broad.component.css']
})
export class BroadComponent implements OnInit, OnChanges{
@Input() options:Array;
@Output() onCollect = new EventEmitter<number>();
items:any = [];
ngOnInit() {
this.items = this.options
}
getNum(value){
this.onCollect.emit(value);
}
}
评论