我在默認選中項目時遇到問題。默認複選框正在工作,但是當我按下一個按鈕來顯示所有選中的項目時,默認檢查並未顯示(它們顯示爲未選中狀態),但是如果我取消選中它並再次檢查它,那麼它就可以工作。我無法找到問題,這是我的代碼:默認選中的複選框未顯示在結果中
<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