jeudi 10 janvier 2019

Checkboxes generated with ngFor array not updating when array changes

I have an array of items (itemsarray) that need to be represented by checkboxes. I have another array (addItem) that contains items that have already been checked.

Whenever addItem changes in the background due to a user selection, the checkboxes do not update. In addition, if an element is manually removed from addItem, the checkbox does not update.

<div class="form-group">
   <label class="control-label col-sm-12" for="secname">Choose Your Items</label>
   <div class="col-sm-10" *ngFor="let item of itemsarray; let i=index">
       <input type="checkbox" [checked]='additem.indexOf(item)>-1' (click)='checkditem($event,item)' >
   </div>
</div>




Aucun commentaire:

Enregistrer un commentaire