簡體   English   中英

如何在單行和每列中僅選擇單選按鈕?

[英]How can I choose just one Button in the Radio per row and per column?

我正在用Angular編程,只是想給機會單擊每行和每列的按鈕。 你該怎么做?

這是我已經擁有的代碼:

component.html:

 <div class="kan1FuerLinks">
    <div class="kan1" *ngFor="let test of tests; let i = index">
     <a>{{test}}</a>
        <mat-radio-group >
          <mat-radio-button (click)="getValue(i, 1)" value="1" [disabled]="arrayValue[i][1]">1</mat-radio-button>
          <mat-radio-button (click)="getValue(i, 2)" value="2" [disabled]="arrayValue[i][2]">2</mat-radio-button>
          <mat-radio-button (click)="getValue(i, 3)" value="3" [disabled]="arrayValue[i][3]">3</mat-radio-button>
          <mat-radio-button (click)="getValue(i, 4)" value="4" [disabled]="arrayValue[i][4]">4</mat-radio-button>
          <mat-radio-button (click)="getValue(i, 5)" value="5" [disabled]="arrayValue[i][5]">5</mat-radio-button>
          <mat-radio-button (click)="getValue(i, 6)" value="6" [disabled]="arrayValue[i][6]">6</mat-radio-button>
        </mat-radio-group>
      {{buttonValue}}
    </div>

component.ts:

getValue(getI: number, val: number) {
this.buttonValue[getI][val] = val;
for (let i = 0; i < this.tests.length; i++) {
  for (let j = 0; j < 6; j++ ) {
    if (this.buttonValue[getI][j] === this.buttonValue[i][j] && this.buttonValue[getI] !== this.buttonValue[getI]) {
      this.arrayValue[getI][val] = true;
    } else {
    }
  }
}

}

這是行不通的。 請幫我。

抱歉,您的英語不是蛋上的黃色,所以我不明白您的問題,請您重復一遍;)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM