gpt4 book ai didi

javascript - ng-model 没有在单选按钮中更新

转载 作者:行者123 更新时间:2023-11-30 09:46:23 24 4
gpt4 key购买 nike

下面是我的代码,单选按钮被选中 onloadng-modelsession.payment 没有更新。我必须再次选择它才能更新

<li ng-repeat="method in data">
<label>
<input ng-model="session.payment" ng-checked="method.active === 'ACTIVE'"
type="radio" value="{{method.paymentId}}">
<span class="radio-btn"></span>
</label>
</li>

最佳答案

您不应将 ng-checked 与 ng-model 一起使用。不要在加载时设置 ng-checked 指令,只需在 Controller 中设置 session.payment 变量即可。

所以现在你的 HTML 应该是:

<input ng-model="session.payment" type="radio" value="{{method.paymentId}}">

在你的 Controller 中:

$scope.session.payment = method.active === 'ACTIVE';

关于javascript - ng-model 没有在单选按钮中更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38771400/

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