how to save selected checkbox in array, with angular 6

0

I have several checkboxes as follows:

ts:

sectores = [{ sector: "Turismo" }, { sector: "Publico" }, { sector: "Privado" }, { sector: 'Taxis' },{sector:"Carga"},{sector:"Empresarial"}]

html:

 <div class="form-group">
                <div class="form-check custom-control-inline" *ngFor="let data of sectores;let i = index;">
                    <input class="form-check-input" type="checkbox" name="data[{{i}}]" [value]="data.sector" #inputSectores #inputSectores="ngModel" [(ngModel)]="settingUser.sectores[i]">
                    <label class="form-check-label" for="gridCheck">{{data.sector}}</label>
                </div>

            </div>

the defined model or interface is as follows:

settingUser = {
  sectores:[null]
}

My question is how do I keep in the array of sectors, the checbox that the user selects?

    
asked by Eze 02.01.2019 в 22:39
source

0 answers