Search code examples
angularcheckboxmaterialize

materialize css checkbox not working with model variable


this is html

<div class="checkbox checkbox-circle">
       <label>
        <input type="checkbox" [attr.checked]="isSelected ? true : null" class="filled-in"
          (change)="rowToggleSelection(row,$event,i)" />
        <span></span>
      </label>
</div>

there is a button that set true/false to isSelected and it works fine till i change the value of checkbox by clicking on checkbox itself. After click on checkbox it stops working from the buton.


Solution

  • Nothing worked for me, so i used the material icons to achieve the same

    <!-- checked -->
    <i class="material-icons label-icon active" *ngIf="isSelected">radio_button_checked</i>
    <!-- un-checked -->
    <i class="material-icons label-icon" *ngIf="!isSelected">radio_button_unchecked</i>
    

    and some css

    .label-icon {
        font-size: 15px;
        &.active {
            color: $color-active;
        }
    }
    

    this is working perfectly.