How to insert check box value into data base using angular 2?




Asked on December 29, 2017
I am unable to insert the the check box value into data base using angular 2. can any one help me out?

In html i have this check box field.
<input type="checkbox" [(ngModel)]="model.allow_access" name="allow_access">

And in component.ts have this part code.
onUserFormSubmit(form: NgForm) {
   alert("onEmployeeFormSubmit");
  console.dir("form values=="+form.value);

// this.loading = true;
this.userService.saveUser(form.value)
.subscribe(
data => {
alert("updated");
this.router.navigate(['/user-admin/users']);
},
error => {
alert("error="+error);
});
}




Replied on December 29, 2017
You should check what value are you getting from checkbox

console.log(form.controls['allow_access'].value);


Write Answer











©2024 concretepage.com | Privacy Policy | Contact Us