As stated in the question, you mentioned that your input is a checkbox. If there's a typo when declaring the input, it will be treated as a text input instead.
To ensure the correct input type, use the following code:
<input type="checkbox" ng-model="checked"/>
When using ng-model with checkboxes, the associated variable like checked
in this case, will only hold values of true
or false
, which are boolean. Therefore, there's no need to compare them within the ng-class
directive.
Just use
<li ng-class="{selected: checked}" ng-repeat="item in data">
and it will work properly.
If you want to see an example, check out the plunker I made for you here.