如何在Angular 2中设置单选按钮
发布时间:2020-12-17 07:59:26 所属栏目:安全 来源:网络整理
导读:我是Angular 2的新手. 我有一个列表并迭代它并显示为单选按钮,如下所示.现在我想在条件为TRUE时设置check属性.如何在Angular 2中做到这一点? table *ngIf="optionList" tr *ngFor="let op of optionList; let i = index" td input type="radio" name="optra
我是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>
尝试这个
<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> 在线演示:https://embed.plnkr.co/jSht4Do3DzpoVQG2SAwl/ (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |