I'm having trouble rendering dynamic checkboxes with JSON API response.
This 2 ng-repeats:
- Bringing the listing of categories in BD, and;
- ng-model with the selected category listing.
Below my HTML code;
<ul class="list-group">
<li class="list-group-item" ng-repeat="cats in categorias">
<div class="checkbox"><label><input type="checkbox" ng-model="checkbox[item.cats]"><span class="checkbox-material"><span class="check"></span></span></label> {{cats.name}}</div>
</li>
</ul>
JSON/API response (1)
[
{"id":"1","id_module":"1","name":"Esportes"},
{"id":"2","id_module":"1","name":"Entretenimento"},
{"id":"3","id_module":"1","name":"Terror"},
{"id":"4","id_module":"1","name":"Drama"}
]
JSON response (2)
{cats":["1","2"]}
I would like that the checkbox stay checked with the response.
Does anyone have any idea?
ngCheckeddirective. Also, since a checkbox only represents boolean values, you should assign the desired checked value to the model with Angular'sngValuedirective.