mercredi 16 mai 2018

On click of a checkbox, how to set all previous checkbox as checked in angular 4

I have few check boxes having label as (Beginner,Intermediate, Advanced, Expert etc..)

Now I want on click of any checkbox , all previous checkbox should checked.

Ex : If I click on Advanced, only all previous check boxes should get checked except the expert.

Below is the code to get the list of check boxes. Please let me know if any solution is there.

        <div class="cb-cont" *ngFor = "let circle of [1,2,3,4], let i = index;"   >
            <input type="checkbox" class="cb" [attr.id]="'vacancy' + i" (change)="changeCheckbox(i)" [checked]=" (i==0) ? true : false"  >
            <label [attr.for]="'vacancy' + i" ><i class="xico-completed"></i></label>
        </div>


  changeCheckbox(i) {
   var  elem = <HTMLInputElement>event.target

     elem.checked = true;
   }

enter image description here




Aucun commentaire:

Enregistrer un commentaire