角度 ng 检查不适用于无线电 - 2

angular ng-checked is not working for radio - 2

本文关键字:无线电 适用于 不适用 ng 检查 角度      更新时间:2023-09-26
<input type="radio" ng-checked="pooledFunds.acceptPooledFunds == 1">
<input type="radio" ng-checked="pooledFunds.acceptPooledFunds == 1"> {{pooledFunds.acceptPooledFunds}} , {{pooledFunds.acceptPooledFunds == 1}}

并且我有一个 JSON 对象分配给控制器中的范围变量,例如

$scope.pooledFunds = {"acceptPooledFunds" : 1};
使用 {{pooledFunds.acceptPooledFunds}} 打印时,值 pooledFunds.acceptPooledFunds}} 显示 1,{

{pooledFunds.acceptPooledFunds == 1}} 显示 true。

但是单选按钮没有变成选中模式。我已经检查了这个链接:角度ng-check不适用于无线电

而且没有帮助。

试试这个

<input type="radio" ng-model="pooledFunds.selectedVal" name="pooled" />
<input type="radio" ng-model="pooledFunds.selectedVal" name="pooled" />

爪哇语

$scope.pooledFunds.selectedVal = 1; 

使用ng-model,如果将模型的值设置为 true/false,那么它应该可以工作。

工作演示