Reputation: 9002
item.imposed is either 1, or 0.
In order for a checkbox to mark as checked, the value must be true or false.
<input type="checkbox" ng-model="item.imposed">
You cannot use a filter inside of ng-model, how can this be accomplished simply and correctly?
Upvotes: 5
Views: 3852
Reputation: 963
You can use ng-value-true to tell angular that your ng-model is a string.
I could only get ng-true-value working if I added the extra quotes like so (as shown in the official Angular docs - https://docs.angularjs.org/api/ng/input/input%5Bcheckbox%5D)
ng-true-value="'1'"
Upvotes: 3
Reputation: 20063
You can use ngChecked
, but you won't get any binding back to your model:
Or you can use ngTrueValue
and ngFalseValue
, but you HAVE to use a string (not an int):
Or you can use a custom directive... it's pretty lame right now.
Upvotes: 11