I have a checkbox which when clicked pushes in an array of name perm_telas, however when I select an already selected check again it is not correctly removing the array value.
I've tried something like:
@ViewChildren('myItem') item; //Aqui é meu check
perm_telas = []; //Aqui é meu array
OnCheckboxSelect(id, event) { //Caso ocorra um check na tela, adiciona para o array perm_telas o id daquela tela.
if (event.target.checked === true) {
this.perm_telas.push(id);
console.log(this.perm_telas);
}
if (event.target.checked === false) {//Caso clique em um já checado, retira aquele id do.
this.perm_telas = this.perm_telas.filter((item) => id !== id);
}
}
The insertion is occurring correctly, I believe something is wrong with my pulling logic from the array.