I have the following table with 3 checkboxes. I assigned each one its own model.
I have a button which I want to be disabled unless any one of the 3 checkbox models are true.
However I'm confused since I expected to use
<button " ng-disabled="!mt0 || !mt1 || !mt2">Reassign</button>
since if any of those were to be true the button should not be disabled.
However, the opposite worked:
<button ng-disabled="!mt0 && !mt1 && !mt2">Reassign</button>
Why?
See plnkr here: http://plnkr.co/edit/yURa3g0aNjDyfEvjK2D0?p=preview
The ng-disabled directive sets the disabled attribute of a form field (input, select, or textarea). The form field will be disabled if the expression inside the ng-disabled attribute returns true. The ng-disabled directive is necessary to be able to shift the value between true and false .
To disable elements just use attribute disabled rather than true or false. To enable it again, you need to remove the disabled attribute. In your code [attr. disabled] is setting the value to true or false, what you need is just use [disabled] instead of [attr.
You can do this to achieve what you want: fiddle
<div ng-app>
<input type="checkbox" ng-model="mt0">
<input type="checkbox" ng-model="mt1">
<input type="checkbox" ng-model="mt2">
<button ng-disabled=" (mt0||mt1||mt2) ? false : true">Reassign</button>
</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With