I have the following checkbox:
<div *ngFor="let tela of telas" class="custom-control custom-checkbox check">
<input type="checkbox" #myItem (change)="OnCheckboxSelect(tela.id, $event)" value="{{tela.id}}" id="{{tela.nome_tela}}" name="{{tela.nome_tela}}" class="custom-control-input">
<label class="custom-control-label" for="{{tela.nome_tela}}">{{tela.nome_tela}}</label>
</div>
It triggers the following function when I check for an option:
OnCheckboxSelect(id, event) {
if (event.target.checked === true) {
this.selectedIds.push(id);
}
if (event.target.checked === false) {
this.selectedIds = this.selectedIds.filter((item) => item !== id);
}
}
But at this point I need to list the permissions of a certain user's screen for later editing:
alteraOperador(operador: any){
this.operador = operador;
console.log(this.operador.tabela_perm);
for(let i=0;i<this.operador.tabela_perm.length;i++){
this.selectedIds.push(this.operador.tabela_perm[i]);
}
}
How can I do when I run this function (changeOperator) to check the checkbox contained in this.operator.permantab?