How do I define a checkbox in an angular form that is checked when the model evaluates to true (anything like "yes", "1", 1,...) and is unchecked when the model evaluates to false ("0", 0, undefined, ...)? I get the data from a rest service and the represantation of true and false can vary. If the user changes the value in the form it should be set to "1" (on) or "0" (off). If he changes it again it should be set to it's original value and marked as unchanged. I'd like to write markup like:
<input type="checkbox" ng-model="value1" my-custom-directive>
<input type="checkbox" ng-model="value2" my-custom-directive>
true/falsevalue for theng-modelvariables. Put a$watchon$scope.server_value1& update$scope.value1accordingly when the former changes.