我在默认选中项目时遇到问题。默认复选框正在工作,但是当我按下一个按钮来显示所有选中的项目时,默认检查并未显示(它们显示为未选中状态),但是如果我取消选中它并再次检查它,那么它就可以工作。我无法找到问题,这是我的代码:默认选中的复选框未显示在结果中
<ion-checkbox value="{{godina['title']}}" style="width: 200px;margin: 0 auto;" ng-model="checkItems[godina['title']]" ng-click="print()" ng-checked="godina.checked" ng-repeat="godina in godine">{{godina["title"]}}</ion-checkbox>
JS:
$scope.godine = [
{ id: 'Duh', title: '0',checked : false },
{ id: 'Duh2', title: '1',checked : false },
{ id: 'Duh3', title: '2',checked : true},
]
这是JS的所有检查项目:
var array = [];
for (i in $scope.checkItems) {
alert($scope.checkItems[i]);
if ($scope.checkItems[i] == true) {
array.push(i);
}
}
什么我我做错了?
你可以发布代码按钮点击和相应的JS? – Vivz