vendredi 20 mars 2020

Material Design - disable checkbox if

I've got a table of items with checkbox and would like to disable them when user check 15 items.

My code is:

  <mdc-checkbox class="checkbox-primary" [(ngModel)]="item.isChecked"
      (change)="$event ? selection.toggle(row) : null" (click)="$event.stopPropagation()"
      (change)="onChecked(item)" [disabled]="itemList.length > 15">
    </mdc-checkbox>

It's works, but it's disable all of them, so you can't uncheck one of already checked and check another one.




Aucun commentaire:

Enregistrer un commentaire