【发布时间】:2017-10-02 12:18:12
【问题描述】:
我试图根据我从对象中获得的值将单选按钮标记为默认值,它可以是 True 或 False。根据选项,我可以做些什么来标记为默认单选按钮?
<label>This rule is true if:</label>
<label class="form-check-inline">
<input class="form-check-input" type="radio" name="mode" value="true"
[(ngModel)]="rule.mode"> all of the following conditions are true
</label>
<label class="form-check-inline">
<input class="form-check-input" type="radio" name="mode" value="false"
[(ngModel)]="rule.mode"> at least one of the following conditions is true
</label>
我在rule.mode中设置了真假。
【问题讨论】:
-
[attr.checked]="role.mode"
-
@BharatChauhan 这是一个正确的答案,非常适合“仅初始化”设置值。谢谢!
标签: angular object radio-button angular-ng-if