Jeremy Miller Jeremy Miller - 1 year ago 148
AngularJS Question

Input type checkbox Angular to be checked if object value is string of 1

In my controller I have object of properties in which

isSampleData = "1"

this is a string value and if it is "1" then I want the checkbox to be checked

Controller is


HTML template


However I want to not have it in a template but as a checkbox

Can and Should I use ng-model ?

<input type="checkbox"

Obviously that code is not using the

Answer Source

You can also specify value of client.IsSampleData, when checkbox will be unchecked, at example it is '0':

<input type="checkbox" ng-model="client.IsSampleData" ng-true-value="'1'" ng-false-value="'0'">
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download