jeudi 23 février 2017

multiple check boxes in angular 2

In component I have define checkboxes

public groceries = [
{ name: 'Seitan', bought: false },
{ name: 'Almond Meal Flour', bought: false },
{ name: 'Organic Eggs', bought: false }
];

In model I make groceries as string

groceries :string

component.html

<span *ngFor="let grocery of groceries">
        <label>
        <input type="checkbox" name="groceries" [(ngModel)]="user.groceries" 
        [value]="grocery.name">
        
        </label>
      </span>

Issue is that by this when I select one checkbox all others are selected. I am confuse and not on track to implement this checkbox feature.




Aucun commentaire:

Enregistrer un commentaire