Hello everyone, I happen to have the following switch:
<div>
<input class="cheqb" type="checkbox" ng-model="checkstate" ng-change="verificarCheckbox()"> <span>Acepto las condiciones establecidas en las <a href="#" target="_blank">Bases Legales</a> del concurso</span>
</div>
which I need to control its status in order to make a request to the server:
'$ scope.send = function (formData) {
var terminos;
var spam = 2;
$scope.verificarCheckbox = function(){
if($scope.checkstate){
terminos =1;
}else{
terminos =0;
}
}
console.log(terminos);
var name = formData.nombre;
var correo = formData.email;
var rut = formData.rut;
var region = formData.region;
if (name == undefined || correo == undefined || rut == undefined || region == undefined) {
console.log('campos vacios');
}
else {
conection.registro({
id: localStorage.getItem("code"),
nombre: formData.nombre,
correo: formData.email,
rut: formData.rut,
region: formData.region,
cond1: terminos,
cond2: spam
}, function(response){
swal({
title: 'Registro Exitoso!',
timer: 2000,
type: 'success'}).then(
function () {},
// handling the promise rejection
function (dismiss) {
if (dismiss === 'timer') {
console.log('I was closed by the timer')
}
}
)
$location.path('/Bienvenido');
$location.hash('feed');
});
}
};'
My goal is that if it is true
that sends 0 otherwise I send 1
and it does not turn out to be just 1, in the code of the query, the function I put it in $scope.send
that when you click when filling out the form, please help.