We mark all posts with checkboxes:

<input ng-click="selectAllPosts()" class="select-all-posts" type="checkbox"><label class="select-all-posts">{{ selectedText }}</label> 

We display all posts:

  <div class="flagged-post" data-ng-repeat="post in posts" > <input ng-checked="post.checked" ng-model="post.checked" type="checkbox" class="select-post"> 

  $scope.selectedText = 'Select All Posts'; $scope.isAll = false; $scope.selectAllPosts = function() { if($scope.isAll === false) { angular.forEach($scope.posts, function(post){ post.checked = true; }); $scope.isAll = true; $scope.selectedText = 'Deselect All Posts'; } else { angular.forEach($scope.posts, function(post){ post.checked = false; }); $scope.isAll = false; $scope.selectedText = 'Select All Posts'; } }; $scope.getFullName = function( post ) { post.checked = false; }; $scope.selectedPostsFilter = function () { return $filter('filter')($scope.posts, {checked: true}); }; 

How to get an array of selected objects to go further forEach'om?

  $scope.removeSelectedPosts = function () { angular.forEach(selectedObj, function(post) { //что-то делаем }); }; 

Closed due to the fact that the essence of the issue is incomprehensible to the participants Grundy , Bald , aleksandr barakin , user207618, user194374 Sep 5 '16 at 10:03 .

Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • the selectedPostsFilter function just returns all selected posts - Grundy

2 answers 2

You can check for true / false

  document.getElementById('индекс').checked 

and compile it into an array using array.push and then it’s already a matter of technique (foreach)

    Idle, like this:

     var box_id='id_form';//id формы, или чего там у тебя есть, в чем эти чекбоксы находятся var ins = document.getElementById(box_id).getElementsByTagName('input');//Все input'ы в форме var cheks_obj = [];//Сюда будем записывать нашу выборку for(var i in ins){ /* Если это - чекбокс и он отмечен - загоняем в массив*/ if(ins[i].type=="checkbox"&&ins[i].checked){cheks_obj.push(ins[i]);} }