Here I have some checkbox and I want to save their data value not ture and false to server. If I click on checkbox then I am pushing group id in array and that group id I want to save in database.
This is the My Html Code:
<input type="checkbox" value="group._id" formControlName="group_id" formControlName="group_id"(change)="getCheckboxValues($event,group)" /><span innerHTML=""></span>
This is my ts file code goes here : here I am pushing only group id
getCheckboxValues(event,id){
debugger;
const checked = event.target.checked;
if (checked) {
debugger
this.selectedGroups.push(id._id ); // push the Id in array if checked
} else {
debugger
const index = this.selectedGroups.findIndex(list => list.user_id == id);//Find the index of stored id
this.selectedGroups.splice(index, 1); // Then remove
}
}
// World View Question
worldViewQuestion = function (data) {
debugger;
// const videodisplaygroup =this.selectedGroups;
if (this.worldViewForm.valid)
data.group_id = $('input[name=group_id]:checked').val();
$("#worldView").val("SAVING...").attr("disabled", true);
this.authService.SaveWorldViewQuestion(data).subscribe(data => {
debugger;
if (data.success) {
//console.log({...this.worldViewForm.value,videodisplaygroup})
$.growl.notice({
title: 'Success',
message: data.message
});
} else {
$.growl.error({
title: 'Error',
message: data.error
});
}
$("#worldView").val("SAVE").attr("disabled", false);
});
}
I want to save group id in videodisplaygroup this is my data structure here is the videodisplaygroup parameter where I want to store value
Please your help would be great
Aucun commentaire:
Enregistrer un commentaire