1

html file:

     <html>
   <body>
      <label>
    <input type="checkbox" name="postcheckbox" />
        demo checkbox
    </label>
</body>
</html>

I want to get the value of changed state of checkbox in my controller.

Deep Shah
  • 39
  • 7

1 Answers1

0

By using Js

var checkbox = document.querySelector("input[name=postcheckbox]");

checkbox.addEventListener('change', function() {
  if (this.checked) {
    console.log("Checkbox is checked..");
    //pass to model

  } else {
    console.log("Checkbox is not checked..");
    //pass to model

  }
});