The idea was to send true checkbox values from mobile to API so I can place an order with selected condiments, however I cant to get a grasp on it. Condiments are returned from HTTP GET call to API.
<ion-checkbox ng-repeat="condiment in condiments" ng-model="condiment.checked"
ng-checked="checkItem(condiment.id)">
{{condiment.name}}
{{condiment.price}}
</ion-checkbox>
It calls the function:
$scope.checkItem = function (id) {
return $scope.condiments[id-1].checked = true;
};
(minus 1 is because ID starts at 1, and array at 0) But it is not called when checked/unchecked, but rather it makes all my resources checked by default, and once I click to uncheck them, nothing changes.
Property 'checked' is not part of the original JSON API output for the condiment. It has ID, name and price.
Question:
Is there a less painful way to send checked ID's back to server?
Edit:
I tried to set the default variables before, but that does nothing:
for(var i=0; i<$scope.condiments; i++){
$scope.condiments[i].checked = false;
}