admin管理员组文章数量:1426203
Filters, I want to select first one radio button.
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>
Filters, I want to select first one radio button.
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>
Share
Improve this question
asked Jun 20, 2015 at 7:01
Uttam PanaraUttam Panara
5492 gold badges10 silver badges28 bronze badges
1
- and if i want to generate click event of it then it is possible? – Uttam Panara Commented Jun 20, 2015 at 7:19
4 Answers
Reset to default 3Use 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 plementary 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">
Or Use
ng-checked="$first"
you can use $first also
<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" ng-checked="$first">
<div class="item-content">
{{restorent_type.RESCOD}}
</div>
<i class="radio-icon ion-checkmark"></i>
</label>
</div>
It's easy, you can do this in your controller:
restaurant_types[0].types = true;
check first restaurant_types[0].types
to true
Good Quation Try This Code
angular.module "myApp", []
angular.module("myApp").controller "myCtrl", ($scope) ->
$scope.keywords = [{name: "kw1", checked: false}, {name: "kw2", checked: true}]
本文标签: javascriptHow to check first checkbox from ngrepeat loop in angular jsStack Overflow
版权声明:本文标题:javascript - How to check first checkbox from ng-repeat loop in angular js? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745422467a2657962.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论