mercredi 30 novembre 2016

All checkboxes are selected (or not) by default when loading model in Angular2

I have a weird issue.

In my html pages, I have the following code:

<tr *ngFor="let role of userRoles" style="width:100%;" >
    <td style="width:37px;">
        <input class="uicheckbox" type="checkbox" [(ngModel)]="role.IsActive" name="isActive" (click)="onCheck(role)" />
    </td>
    <td></td>
</tr>

I'm bringing in a model that has an Array of roles, some of which have set IsActive to true, some to false. The checkbox should be checked based on the role.IsActive property. But for some reason, all checkboxes are (un)checked when the model loads. Why is this happening?




Aucun commentaire:

Enregistrer un commentaire