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

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -