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?
You can use ngChecked
, but you won't get any binding back to your model:
http://jsfiddle.net/fMBQj/
Or you can use ngTrueValue
and ngFalseValue
, but you HAVE to use a string (not an int):
http://jsfiddle.net/fMBQj/1/
Or you can use a custom directive... it's pretty lame right now.
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'"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With