过滤器,我想先选择一个单选按钮。
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>
你也可以先用$
<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>
如果我们将Angular插值表达式放入这样的属性中,那么当浏览器删除该属性时,绑定信息将会丢失。 ngChecked指令解决了checked属性的这个问题。浏览器不会删除此补充指令,因此提供了存储绑定信息的永久可靠位置。
<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"
这很容易,您可以在控制器中执行此操作:
restaurant_types[0].types = true;
首先检查restaurant_types[0].types
到true
好的Quation尝试此代码
angular.module "myApp", []
angular.module("myApp").controller "myCtrl", ($scope) ->
$scope.keywords = [{name: "kw1", checked: false}, {name: "kw2", checked: true}]