How to save multiple checkbox value into database i have written a code below i cant understand how to pass the $scope.selection array into url please see below code and suggest me
<tr ng-repeat="result in results">
<td <input type="checkbox" name="selectedadd" ng-model="addvalue" value="{{result.user_id}}" ng-checked="selection.indexOf(result.user_id) > -1" ng-click="toggleSelection(result.user_id)"> {{result.name}}</td>
</tr>
<td ng-click="linkToSelectedPlayer()" value="{{result.user_id}}"> <i class=""></i> Selected Add</a></td>
$scope.selection=[];
$scope.linkToSelectedPlayer = function(){
console.log($scope.selection);
//Getting response with $scope.selection
//Array[156,355,665,666]
$http.post("v1/xyz/"+$scope.user.user_id+"/abc/"+$scope.selection)
.success(function (response){
$location.path('/home/');
}).error(function (data) {
alert(“invalid”);
});
// toggle selection for a given employee by id
$scope.toggleSelection = function toggleSelection(userid) {
var idx = $scope.selection.indexOf(userid);
// is currently selected
if (idx > -1) {
$scope.selection.splice(idx, 1);
}
// is newly selected
else {
$scope.selection.push(userid);
}
};
};
Thanking you in advance early reply will be highly apprecaited