我是Angular 2的新手.
我有一个列表并迭代它并显示为单选按钮,如下所示.现在我想在条件为TRUE时设置check属性.如何在Angular 2中做到这一点?
<table *ngIf="optionList">
<tr *ngFor="let op of optionList; let i = index">
<td>
<input type="radio" name="optradio" *ngIf=" (CONDITION HERE) ? 'checked' : 'non' ">
<label>{{op.option_text}} </label>
<td>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud)
Tie*_*han 36
试试这个
<table *ngIf="optionList">
<tr *ngFor="let op of optionList; let i = index">
<td>
<input type="radio" name="optradio" [checked]=" (CONDITION HERE)">
<label>{{op.option_text}} </label>
<td>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud)
在线演示:https://embed.plnkr.co/jSht4Do3DzpoVQG2SAwl/
你可以这样使用它
<input type="radio" name="optradio" [checked]="savedVal == currentRadioVal ? true : false" >
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
40791 次 |
最近记录: |