1

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?

2 Answers 2

3

Use "ng-model" in angular

<input type="checkbox" ng-model="checked"/>
<button ng-disabled="!checked"> MyInput </button>
Sign up to request clarification or add additional context in comments.

2 Comments

But outside of button? I can?
Of course : the ng-model named "checked" will be available everywhere (you must be inside your controller call ng-controller of course)
3

Put ng-model binding on your input:

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

And inside your "Share" function:

if($scope.checked){
   //do some action if checkbox is checked
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.