【发布时间】:2022-02-09 22:15:41
【问题描述】:
如果 type.location=='none',我正在尝试检查单选按钮,但这似乎不起作用。
<ng-container *ngFor="let type of topping.type">
<input
type="radio" class="mr-1" name="{{topping.name}}"
id="{{type.location}}" [(ngModel)]="topping.location"
[value]="type.location"
checked="type.location=='none'">
</ng-container>
【问题讨论】:
-
用方括号括起来
[checked] -
那行不通。
-
你不能同时使用
ngModel和checked。 -
只有
topping.location='none',是的,不使用[已选中]