Reputation: 6610
I have a checkbox whose checked state (ng-checked
) is based on a computed property (ng-checked="someFunction()"
).
For the sake of example, let's assume its check state should always be checked, ie: ng-checked="true"
.
However, clicking on the checkbox will uncheck it, meaning there's a disconnect between the ng-checked
declaration and the actual state of the checkbox:
<input type="checkbox" ng-checked="true">
So why does clicking the checkbox make it unchecked if ng-checked
is always true?
Upvotes: 0
Views: 1341
Reputation: 303
ng-checked is not intended to lock the value of a checkbox, it is a one way binding which updates the checkbox only when the property its bound to is updated. Also you can not bind to primitives (in this case a boolean value), you must bind to a property of an object.
If you want to disable this checkbox, use the disabled="true" attribute.
Upvotes: 4