Answer the question
In order to leave comments, you need to log in
How to get an array of checkboxed elements?
We mark all posts with checkboxes:
<input ng-click="selectAllPosts()" class="select-all-posts" type="checkbox"><label class="select-all-posts">{{ selectedText }}</label>
<div class="flagged-post" data-ng-repeat="post in posts" >
<input ng-checked="post.checked" ng-model="post.checked" type="checkbox" class="select-post">
<div>Что-то</div>
</div>
$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});
};
$scope.removeSelectedPosts = function () {
angular.forEach(selectedObj, function(post) {
//что-то делаем
});
};
Answer the question
In order to leave comments, you need to log in
What is it?
$scope.selectedPostsFilter = function () {
return $filter('filter')($scope.posts, {checked: true});
};
This module will help you to work with checkboxes vitalets.github.io/checklist-model . With it, it will be easier then to perform actions on all selected elements.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question