rahul aggarwal rahul aggarwal - 1 year ago 64
AngularJS Question

Binding Checkbox based on the value of the field in AngularJS

I want to check/uncheck checkbox based on the value of the field


When services.Register.IsTest=True
My checkbox should be checked else not

my checkbox

<input type="checkbox" id="patReturned" value="Returned">

I am new to AngularJS. Please help.


Answer Source

Your are looking for the ngChecked directive from AngularJS

Sets the checked attribute on the element, if the expression inside ngChecked is truthy.

Use it like this

<input type="checkbox" id="patReturned" value="Returned" ng-checked="services.Register.IsTest">
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download