mercredi 5 septembre 2018

Count how many checkboxes are checked with angular 6

Here is my checkboxes which i generate with ngFor

<mat-checkbox [checked]="i <= map[l][k]" [(ngModel)]="check.checked"  (change)="checkAll($event.checked, i ,k,  l)" (ngModelChange)="changed(i)"> - </mat-checkbox>

when i click a checkbox, all the checkboxes with inferior index are checked as well and the checkboxes with superior index are unchecked

here the function that i use

  checkAll(c, i: number, k, l) {
if (c) {
  this.map[l][k] = i;

} else {
  this.map[l][k] = i - 1;
}

}

i would like to count how many checkboxes are checked and display the result in my HTML template, how could i achieve this ?




Aucun commentaire:

Enregistrer un commentaire