I have the following array:
$scope.profile.preferencias = [7,5,3,8,4];
EDIT My Category array looks like this:
[
{
"id": 2,
"descricao": "Entomologia",
"dataCriacao": "0001-01-01T00:00:00",
"isActive": true,
"isFixed": true
},
{
"id": 3,
"descricao": "Fisiologia",
"dataCriacao": "0001-01-01T00:00:00",
"isActive": true,
"isFixed": true
}
]
My ion-checkbox looks like this:
<ion-checkbox ng-repeat="category in categories | toArray | orderBy:'descricao'" name="group" ng-model="profile.preferencias[category.id]">{{category.descricao}}</ion-checkbox>
The output selected is:
{
"7": true,
"5": false,
"3": true
}
How can i sent only the number to my json, so it will save like the $scope above, and when the page is reloaded, the checkboxes comes back checked?
Thanks!