Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set false value to ng-model when my checkbox is not selected

I want to have false value when user checkbox is not checked.
HTML Code

On checking the checkbox value is setting as 'true' in addUser.isAllOrgSelected. But when checkbox is not checked value is not getting set to 'false'.

           <input type="checkbox" id="checkbox-1-1" class="regular-checkbox" 
           ng-true-value="true" ng-false-value="false" ng-
             model="addUser.isAllOrgSelected">
                 <label for="checkbox-1-1"></label>
               <span class="check-text">ALL</span>
like image 623
Java User Avatar asked Oct 29 '22 07:10

Java User


1 Answers

you can use the ng-checked directive.

<input type="checkbox" 
    ng-model="addUser.isAllOrgSelected" 
    ng-true-value="true" 
    ng-false-value="false" 
    ng-checked="addUser.isAllOrgSelected " />

see example here

like image 123
Karim Avatar answered Nov 09 '22 10:11

Karim