How to check if checkbox is checked in Angular JS?


I have HTML form with fields: input, textarea. All fields have attribute required and submit button have:

<div ng-click="Share()" ng-disabled="shareForm.$invalid"</div>

How I can check if checkbox is checked or not and disable button?

Problem courtesy of: Hamed


Use "ng-model" in angular

<input type="checkbox" ng-model="checked"/>
<button ng-disabled="!checked"> MyInput </button>
Solution courtesy of: tektiv


Put ng-model binding on your input:

<div ng-click="Share()" ng-model="checked" ng-disabled="shareForm.$invalid"</div>

And inside your "Share" function:

   //do some action if checkbox is checked
Discussion courtesy of: Oleg Yudovich

This recipe can be found in it's original form on Stack Over Flow.