I made it to page 3 on a google search, seems nobody uses single checkboxes anymore on their pages, and of course, the angular documentation (or any documentation) fails to mention how to validate one single frikkin checkbox.
just like this.
<form name="myForm" submit="mySubmitMethod()">
<input type="checkbox" name="mycheckbox" ng-model="myModel.MyCheckbox" />
<button type="submit" ng-disabled="myForm.mycheckbox.$dirty && myform.mycheckbox.$invalid">submit</button>
</form>
So, in my form object, dirty never changes if i click it, and neither does invalid, regardless of the state. this makes no sense. Someone please help. I've been messing with this for a couple of hours now, and i'm unable to find anything on it. Everyone is talking about groups of checkboxes.. I have one. I don't want to write a whole bunch of code for a single checkbox.
Aucun commentaire:
Enregistrer un commentaire