AngularJS check if checkbox is unchecked -


i trying show/hide , adjust ng-required status if checkbox checked, doesn't seem managing variables properly. here examples:

<input type="checkbox" ng-model="checkboxdmodel.value" ng-true-value="'yes'" ng-false-value="'no'"> 

input want required unless checkbox checked in case should hidden , not required:

<div class="form-group" ng-hide="checked.yes">                 <label class="col-sm-3 control-label" for="inputamount">                     <font color="red">*</font>expense amount</label>                 <div class="col-sm-8">                     <input type="number" class="form-control" id="inputamount" data-ng-model="itemamount" step="any" ng-required="checked.no"/>                 </div>             </div> 

http://plnkr.co/edit/f4hdqwwhiwiqvsjl5etx?p=preview

no need ng-true , ng-false.

because checked , unchecked states of checkbox evaluate truthy or untruthy, can drop checkbox ng-model value right wherever want. in case of ng-required, invert value !.


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

order - Notification for user in user account opencart -