lundi 13 août 2018

how to reset checkboxes in angular 4

I have a check box binded to an array--the array is type Interface which is the following:

        export interface IdataTypes {
          Categories: string,
          isSelected: boolean,
        }

here is how bounded it:

      <div *ngFor="let DT of DTofSectores">
        <input type="checkbox"
               name="DTofSectors"
               formControlName="DTofSectors"
               value=""
               (change)="onDataTypeClick($event,DT,'DTofSectors')"
                           >
        
      </div>

the check box is filled according to what is selected from a dropdown list. My question is: how can I clear all checked check box when I change the dropdown.

EDIT: I have tried to set the binded array to null whenver the dropdown changes as following

        this.DSofSectores.push({
          category :"",
          isSelected : false
        })

but what happen is that, the array remain empty do i have no checkbox then!




Aucun commentaire:

Enregistrer un commentaire