2
I’m having trouble rendering dynamic checkboxes with JSON API response.
Are 2 ng-repeats :
- Bringing the list of existing categories into the dataset, and;
- ng-model with the list of chosen categories.
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>
Below my answer JSON/API (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"}
]
Another JSON exit (2)
{cats":["1","2"]}
I would like the checkboxes to be checked with the above answer.
Anyone have any idea?