mercredi 2 mars 2016

Why angular `ng-repeat` have different checkbox differentiate behavior then listing out checkbox manually?

If I list out checkboxes manually

<ul>
    <li>
        <input type="checkbox" ng-model="checkState"/>
    </li>
    <li>
        <input type="checkbox" ng-model="checkState"/>
    </li>
</ul>

Checking one checkbox checks all of the checkbox.

But if I use ng-repeat

<div>
    <ul>
        <li ng-repeat="elem in someArray">
            <input type="checkbox" ng-model="checkState"  />
        </li>
    </ul>
</div>

Checking one checkbox only checks one of them

Is there a reason for this? From the DOM they both looks the same.




Aucun commentaire:

Enregistrer un commentaire