gpt4 book ai didi

javascript - Angular ng-checked 不适用于 radio - 2

转载 作者:行者123 更新时间:2023-11-27 22:59:48 25 4
gpt4 key购买 nike

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

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

我有一个 JSON 对象分配给我的 Controller 中的范围变量,例如

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

使用 {{pooledFunds.acceptPooledFunds}} 打印时,pooledFunds.acceptPooledFunds 的值显示 1,而 {{pooledFunds.acceptPooledFunds == 1}} 显示 true。

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

这没有帮助。

最佳答案

试试这个

<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

关于javascript - Angular ng-checked 不适用于 radio - 2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37208746/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com