gpt4 book ai didi

javascript - 如何检查angular js中ng-repeat循环的第一个复选框?

转载 作者:行者123 更新时间:2023-11-30 07:59:49 25 4
gpt4 key购买 nike

过滤器,我想选择第一个单选按钮。

Restorent1 ✔ | restorent 2 | restorent3 | restorent4

<div ng-repeat="restorent_type in restaurant_types" style="margin:5px;" class="col col-offset-10">
<label class="item item-radio radio-label {{restorent_type.RESCOD}}">
<input type="radio" name="group" ng-model="restorent.types" value="{{restorent_type.RESCOD}}" ng-click="filters.RESCOD = restorent_type.RESCOD">
<div class="item-content">
{{restorent_type.RESCOD}}
</div>
<i class="radio-icon ion-checkmark"></i>
</label>
</div>

最佳答案

使用ng-checked

If we put an Angular interpolation expression into such an attribute then the binding information would be lost when the browser removes the attribute. The ngChecked directive solves this problem for the checked attribute. This complementary directive is not removed by the browser and so provides a permanent reliable place to store the binding information.

<input type="radio" name="group" ng-model="restorent.types" value="{{restorent_type.RESCOD}}" ng-checked="$index === 1 ? true : false" ng-click="filters.RESCOD = restorent_type.RESCOD">

或者使用

ng-checked="$first"

关于javascript - 如何检查angular js中ng-repeat循环的第一个复选框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30951246/

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