Angular Version 13
Here Is my working Code..
Declare First...
lang_array: any[] = [];
lang_values:any={};
If CheckBox Is Selected Then Output Will Be true OtherWise false.
**My Table In HTML File**
<div class="table-responsive">
<table class="table table-hover table-bordered table-striped" (change)="CheckBox($event)">
<thead>
<tr>
<th scope="col">Language</th>
<th scope="col">Speak</th>
<th scope="col">Write</th>
<th scope="col">Read</th>
</tr>
</thead>
<tbody>
<tr >
<th>Marathi</th>
<td><input value="marathi_speak" type="checkbox"></td>
<td><input value="marathi_write" type="checkbox"></td>
<td><input value="marathi_read" type="checkbox"></td>
</tr>
<tr>
<th>Hindi</th>
<td><input value="hindi_speak" type="checkbox"></td>
<td><input value="hindi_write" type="checkbox"></td>
<td><input value="hindi_read" type="checkbox"></td>
</tr>
<tr>
<th>English</th>
<td><input value="english_speak" type="checkbox"></td>
<td><input value="english_write" type="checkbox"></td>
<td><input value="english_read" type="checkbox"></td>
</tr>
</tbody>
</table>
</div>
My Code In .ts File
CheckBox(e: any) {
console.log(e.target.attributes[1].value);
if(e.target.attributes[1].value)
{
if( this.lang_array.includes(e.target.attributes[1].value))
{
console.log("value exist");
const index=this.lang_array.indexOf(e.target.attributes[1].value);
console.log(index);
if(index>-1)
{
this.lang_array.splice(index,1)
this.lang_values=this.lang_array;
console.log("Language values",this.lang_values);
const marathi_values=
{
marathi_speaks:this.lang_values.includes("marathi_speak"),
marathi_write:this.lang_values.includes("marathi_write"),
marathi_read:this.lang_values.includes("marathi_read"),
}
console.log("marathi_values",marathi_values);
const hindi_values=
{
hindi_speaks:this.lang_values.includes("hindi_speak"),
hindi_write:this.lang_values.includes("hindi_write"),
hindi_read:this.lang_values.includes("hindi_read"),
}
console.log("Hindi_values",hindi_values);
const english_speak=
{
english_speak:this.lang_values.includes("english_speak"),
english_write:this.lang_values.includes("english_write"),
english_read:this.lang_values.includes("english_read"),
}
console.log("English_values",english_speak);
}
}
else {
this.lang_array.push(e.target.attributes[1].value);
this.lang_values=this.lang_array;
console.log(this.lang_values);
const marathi_values=
{
marathi_speaks:this.lang_values.includes("marathi_speak"),
marathi_write:this.lang_values.includes("marathi_write"),
marathi_read:this.lang_values.includes("marathi_read"),
}
console.log("marathi_values",marathi_values);
const hindi_values=
{
hindi_speaks:this.lang_values.includes("hindi_speak"),
hindi_write:this.lang_values.includes("hindi_write"),
hindi_read:this.lang_values.includes("hindi_read"),
}
console.log("Hindi_values",hindi_values);
const english_speak=
{
english_speaks:this.lang_values.includes("english_speak"),
english_write:this.lang_values.includes("english_write"),
english_read:this.lang_values.includes("english_read"),
}
console.log("English_values",english_speak);
}
}
else{
console.log("next Block");
}
}
children[0]islabelin some rows.