2016-05-13 42 views
0
<input type="radio" ng-checked="pooledFunds.acceptPooledFunds == 1"> 

<input type="radio" ng-checked="pooledFunds.acceptPooledFunds == 1"> {{pooledFunds.acceptPooledFunds}} , {{pooledFunds.acceptPooledFunds == 1}} 

,我必须使用{{pooledFunds打印时JSON对象分配给范围变量在我的控制器等角NG-检查不工作的无线电 - 2

$scope.pooledFunds = {"acceptPooledFunds" : 1}; 

值pooledFunds.acceptPooledFunds。 acceptPooledFunds}}显示1和{{pooledFunds.acceptPooledFunds == 1}}显示为true。

但单选按钮没有变成检查模式。 我已经检查了这个链接:angular ng-checked is not working for radio

它并没有帮助。

+0

你想收音机或复选框? –

+0

没有检查收音机。请参阅[angular docs](https://docs.angularjs.org/api/ng/input/input%5Bradio%5D)。 – jlulloav

回答

0

试试这个

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

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

的Javascript

$scope.pooledFunds.selectedVal = 1; 

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

工作Demo

+0

感谢您的及时回复。我会接受这是正确的答案。好的,我将用ng-model替换ng-checked。 –

+0

另外一种工作模式,我为自己尝试过:仅供其他人参考:http://mcaf.ee/ugr80a –