rahul aggarwal rahul aggarwal - 2 months ago 10
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.



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">