I have a checkbox and I want to control its action from the controller when false
or true
.
here is the Html :
<md-checkbox ng-model="checkstate" aria-label="Checkbox 1" ng-true-value="'prioritario'" ng-false-value="'Normal'">
{{checknull}}
</md-checkbox>
"The end is that the controller controls the action."
When logearme I receive a JSON: id_servicio: "38,39" , I separate them with a split and I store them in localStorage staying in:
- LoginData.getData (). service_id.split (",") [0] ,
- LoginData.getData (). service_id.split (",") [1]
Then in the controller I make a request to my DB and in then I do the following:
.then(function(data) {
var dat = data.data;
$scope.tickets = [];
$scope.verificarCheckbox = function() {
if ($scope.checkstate) {
for (var i = 0; i < dat.length; i++) {
dat[i]
var ticket = {
numero: dat[i].numero,
rut: dat[i].rut,
servicio_id: LoginData.getData().id_servicio.split(",")[0]
};
$scope.tickets.push(ticket);
}
} else {
for (var i = 0; i < dat.length; i++) {
dat[i]
var ticket = {
numero: dat[i].numero,
rut: dat[i].rut,
servicio_id: LoginData.getData().id_servicio.split(",")[1]
};
$scope.tickets.push(ticket);
}
}
}
});
The idea is that if I select the checkbox send the fix [0] and if I de-select it send the fix [1]