Recently, I've been working on adding a bulk post delete feature to my system. The idea is to have a list of posts with checkboxes next to each one, and when a user clicks a button, the selected posts should be deleted.
My approach involves assigning each post's id as the value for the checkbox, then passing all the checked values to an Angular controller. From there, the backend can use these ids to search for the corresponding posts and delete them.
Despite my efforts, I'm struggling to figure out how to pass all those values effectively.
Here is a snippet of what I have so far:
<td><input type="checkbox" value="post.id" name="posts"></td>
<button class="btn btn-info pull-middle" ng-show="showDelBtnAndTableHeaders" ng-click="destroySelected(selectedPosts)">Delete Selected Posts</button>
I've also included this function in the controller, but I haven't been able to successfully retrieve the array of values for deletion despite several attempts:
$scope.destroySelected = function (array) {
console.log(array);
Post.destroySelected(array)
.success(function () {
})
};
If anyone has any insights or suggestions on how to improve this process, I would greatly appreciate it. Thank you!