mardi 25 octobre 2016

how to get all the checked values and pass to angular controller?

I have something like a post. I want to add something like a bulk post delete.

I am thinking of making the post's id as value and when a button is clicked, all those checked values will be passed to the angular controller then pass it to the backend to search up for the ids selected and delete them.

But I am not sure how I am able to pass all those values

I only had something simple like this

<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 added something like this in the controller to test if I get it right that I get the array of values but done a few different tries and no luck

    $scope.destroySelected = function (array) {
        console.log(array);
        Post.destroySelected(array)
            .success(function () {

            })

    };

Can someone give me an idea on this? Thanks in advance.




Aucun commentaire:

Enregistrer un commentaire