10

I have a button on a form that I'd like to disable until one or more checkboxes have been selected. This is probably fairly simple to solve, but the button is not disabled when I use !result.isSelected.

This is my button:

<button class="btn btn-success" ng-click="send()"  ng-disabled="!result.isSelected" </button>

And the checkbox:

<input type="checkbox" class="checkbox-row" ng-model="result.isSelected" ng-click="selected()" />

Does anyone know of a better solution? Thanks for your help!

2
  • What selected() in the ng-click do actually? Commented Jul 4, 2015 at 18:01
  • It selects the checkbox to add the items to an array. Commented Jul 4, 2015 at 18:06

1 Answer 1

9

A better solution would be:

<input type="checkbox" class="checkbox-row" ng-model="checked" ng-click="selected()" />

<button class="btn btn-success" ng-click="send()"  ng-disabled="!checked"> </button>
Sign up to request clarification or add additional context in comments.

2 Comments

Welcome.This was fairly a very simple issue you were facing. Please go through this documentation : docs.angularjs.org/api/ng/directive/ngDisabled If it still doesnt help. you are always welcome on stackoverflow.
Will do :).. just needed to understand why it wasn't working the way I had it.

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.