I am new to angular js. I have a checkbox with a table .
<td><input type="checkbox" ng-if="report.attributes.message.length > 0" ng-bind="report.attributes.message" ng-click="getcheckedData(report.attributes.message)"></td>
Here , I have a method getcheckedData()
. So, In that method
var messages = [];
$scope.getcheckedData = function(SelectedVal) {
$("input:checkbox[type=checkbox]:checked").each(function() {
if ($.inArray(SelectedVal , messages) === -1){
messages.push(SelectedVal);
}
});
return messages;
};
I have an array which I declared globally,.So, I want to take the value of selected checkbox table data into that array. I am able to get that value in array
. So, when user unchecks then the value which is unchecked should also get removed from that array
. So, when user checks then , I have given one button on that I am sending all checked messages to the backend. So, When I uncheck and press the button that time all messages still remain in the array.
$scope.sendAllMessages = function() {
uploadService.SendMessagesToQueue(uploadService.currentFileName,$scope.documentType,messages)
.then(function () {
}, function (error) {
$scope.errorMessage = error.status + " : " + error.statusText;
toastr.error($scope.errorMessage, 'Error : ' + error.status);
if (error.status === 401) {
loginService.authenticationError();
}
})
.finally(function () {
});
};
For button -
<button type="submit"
ng-click = "sendAllMessages()"
class="button-size btn btn-primary">Send
</button>
so, How can I resolve this problem ?
Aucun commentaire:
Enregistrer un commentaire