配列ng-clickに挿入する関数を呼び出すチェックボックスがあります。checkedItems
このチェックボックスに配列の要素を事前入力するにはどうすればよいcheckedItemsですか?
これが私のセットアップからの関連するスニペットです:
<div ng-repeat="c in c_list">
<input type="checkbox" ng-click="checkSelection(c)"/> {{c}}
</div>
$scope.c_list_selected = []
$scope.checkSelection = function (item) {
if ($scope.c_list_selected.indexOf(item) === -1) {
$scope.c_list_selected.push(item);
} else {
$scope.c_list_selected.splice($scope.c_list_selected.lastIndexOf(item), 1);
}
}
ng-bind、ng-modelおよびいくつかの異なるng-checked表現を試しました。どれも機能しませんでした。