ngFor with checkbox you are selecting all values

-1

I have the following checkbox with a repeat structure:

      <div *ngFor="let tela of telas" class="custom-control custom-checkbox check">
        <input type="checkbox" id="{{tela.nome_tela}}" [(ngModel)]="operador.permissao_telas" name="{{tela.id}}" class="custom-control-input" checked>
        <label class="custom-control-label" for="{{tela.nome_tela}}">{{tela.nome_tela}}</label>
      </div>

This is my template:

export class Operador{
    id: number;
    nome: string;
    permissao_telas: number[];
}

In my component I do:

 operador:Operador = new Operador();

The problem is that when I click on some check, all other checks are selected as well.

I've tried indexing and it did not work either.

    
asked by anonymous 23.07.2018 / 22:31

1 answer

0

Remove checked at the end of your input in html

    
25.07.2018 / 09:30