javascript - Show the inverse state of a model in a checkbox -
let's have model such as:
required: bool and checkbox labeled optional [x].
when model value of required true, optional should unchecked, , vice versa.
is there way can bind required model value checkbox, invert shown value , value set when checkbox clicked?
i know can create $watch , thing on own, thought maybe angular provides facility kind of stuff.
this work checkbox input:
<input type="checkbox" ng-model="optional" ng-change="required = !optional" ng-value="!required" /> you need ng-value initial model value.
Comments
Post a Comment