【发布时间】:2015-04-11 14:50:04
【问题描述】:
我有两个来自对象 Web 服务的数组。一个是所有类别,另一个是像这样选择的类别
$scope.categories = [
{ "id": 1, "name": "cat1" },
{ "id": 2, "name": "cat2" },
{ "id": 3, "name": "cat3" },
{ "id": 4, "name": "cat4" }
];
$scope.selected_category = [
{ "id": 1, "name": "cat1" },
{ "id": 2, "name": "cat2" }
];
我的标记是这样的
<div class="form-group">
<label>Category</label>
<div class="clr"></div>
<label class="checkbox-inline" ng-repeat="item in categories">
<input type="checkbox" value="{{item.id}}" ng-model="?" ng-checked="?">
{{item.name}}
</label>
</div>
我不知道如何检查那些被选中的复选框。请帮忙!
谢谢
【问题讨论】:
-
将
checked属性添加到categories,然后使用它来管理已选中的未选中对象...
标签: javascript jquery angularjs