I have a checkbox that is iterated in an ngfor:
<div *ngFor="let tela of telas; let i = index; trackBy: getIndex" class="custom-control custom-checkbox check">
<input type="checkbox" [(ngModel)]=selectedIds[i] (click)="OnCheckboxSelect(tela.id, $event)" #myItem 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>
There is a moment when I get the array of selectedIds again to make changes, however I get the array in the following format:
[1,3,5] These are the screen ids that a user can access, but my ngModel would need to receive: [0: true, 2: true, 4: true]
I'm trying to make a repetition structure to achieve the desired result. I've tried something like:
this.selectedIds = [];
for(let i=0;i<this.operador.tabela_perm.length;i++){
this.selectedIds[this.operador.tabela_perm - 1] = true;
}
But my logic is still wrong. Could someone help me?