2017-09-20 28 views
0

如何讓單選按鈕專注於標籤,並在點擊角度2時進入選擇狀態?打字稿中的單選按鈕焦點/ angular2

<div class="radio-group-container"> 
    <md-radio-group class="radio-group" [(ngModel)]="choice" tabIndex="11" (click)="radioClick()" disableRipple> 
     <md-radio-button class="radio-button" *ngFor="let choice of choices" [value]="choice" tabIndex="13" disableRipple>{{choice}}</md-radio-button> 
    </md-radio-group> 
</div> 

回答

0

所有使用創建的單選按鈕在代碼中都具有相同的tabIndex。嘗試將其替換爲

<md-radio-button class="radio-button" *ngFor="let choice of choices; let i=index" [value]="choice" tabIndex="index" disableRipple>{{choice}}</md-radio-button> 
+0

如果tabindex應該從11開始,那麼如何初始化索引? – user3579341

+0

我無法使單選按鈕上的tabindex工作,但按照邏輯,我認爲tabIndex =「11 + index」應該工作 – Vega