I am trying to use Angular to update all input values that have a certain class if another input is NOT checked.
HTML:
<input type="checkbox" class="form-optional" ng-model="user.diffPhysicalLegal" name="diff-physical-legal" ng-change="inputReset()"> My Legal Business Name and/or Legal Business Address are different.
<section class="form-show" ng-show="user.diffPhysicalLegal">
<input class="optional-element" type="text" ng-model="user.legalName" name="legal-name" placeholder="Legal Business Name" ng-required="user.diffPhysicalLegal == true"></br>
<input class="optional-element" type="text" ng-model="user.legalMailingAddress" name="mailing-address" placeholder="Mailing Legal Business Address" ng-required="user.diffPhysicalLegal == true"></br>
<input class="optional-element" type="text" ng-model="user.legalCityStateZip" name="legal-city-state-zip" placeholder="City, State, and Zip Code" ng-required="user.diffPhysicalLegal == true">
</section>
Here's the function I tried writing:
app.js
$scope.inputReset = function(){
if(!$('.form-optional').is(':checked') {
$(this).parent().find('.optional-element').val(null);
}
}
This doesn't work, and I haven't been able to figure out how else to accomplish this. I'm new to Angular so I'm still pretty unfamiliar with how to implement jQuery into my app.js
file, or if I even need jQuery to accomplish this.