I am trying to pass data to an API for the user e-mail subscription status as "Y"/"N". In the controller code " console.log(a.checked)" is undefined.But in regular javascript onclick event for the input element type="checkbox" has the "this.checked" to respond correspondingly as true or false.Why is it not happening here in angularJs.
// this is my html code with angular directive ng-click
<label for="mail_sub">E-mail subscription</label>
<input id="mail_sub" type="checkbox" name=checkbox ng-click="mailsubscription(this)">
// this part of code is of the controller
.controller("registerCtrl", function($scope,$state,userProcess){
$scope.mailsubscription = function(a){
console.log(a);
console.log(a.checked);// console output is: "undefined"
signupinfo = {};
if(a.checked){
signupinfo.u_mail_subscription = 'Y';
}else{
signupinfo.u_mail_subscription = 'N';
}
console.log(signupinfo);
};
/*$scope.registerProcess = function(signupinfo){
console.log(signupinfo);
userProcess.signup(signupinfo).sucess(function(response){
if(response.status){
}
})
};*/
});
Aucun commentaire:
Enregistrer un commentaire