Angularjs disable button if checkbox is checked
12,486
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>
Author by
1313
Updated on July 20, 2022Comments
-
1313 almost 2 years
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!
-
Sajal almost 9 yearsWelcome.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.
-
1313 almost 9 yearsWill do :).. just needed to understand why it wasn't working the way I had it.