I've used materialize checkboxes within forms in my single-page angular app, and I need to give these a value based on whether or not they are checked, like 'true' if checked and 'false' if not.
I've tried using the code below to assign values within a button's click handler function in my controller, but angular is returning the error 'TypeError: elem.nodeName is undefined' on load, and the button no longer functions.
if (angular.element('#employeePaymentForm input[type="checkbox"]').is(':checked')) {
angular.element(this).val('Yes');
console.log(angular.element(this).val());
} else {
angular.element(this).val('No');
console.log(angular.element(this).val());
}
Example checkbox HTML:
<div tooltipped class="tooltipped col-xs-12 col-sm-6 col-md-2" data-position="bottom" data-delay="800" data-tooltip="Select to reset hours and pay to zero at period end">
<input id="zeroiseHoursCheckbox" name="zeroiseHoursCheckbox" type="checkbox" class="filled-in notRequired notRequired checkbox">
<label for="zeroiseHoursCheckbox">Zeroise at Period End?</label>
</div>
Aucun commentaire:
Enregistrer un commentaire