Let's say I have this question object:
$scope.question = {
id: 1,
question: 'q?',
required: true,
control: {
type: 'multiple_check',
options: [{
value: '1st option'
}, ... ]
}
}
And this form:
<form name="s.form" novalidate>
<h1></h1>
<label ng-repeat="option in question.control.options">
<input type=" name="xxx"
ng-model="question.answer[$index]" ng-required="question.required" />
</label>
</form>
And I'm stuck now with validation.
I've created a pen for this.
should give me true when form is valid, but it returns true only when all checkboxes in group are checked
should give me true when at least one checkbox is checked, but it actually returns true only when the last checkbox is checked
I want to be able to choose at least one checkbox (one or more) from the group. When at least one is checked the form and group will be valid.
How can I achieve that? Already tried many things but can't make this to work.
Thanks.
Aucun commentaire:
Enregistrer un commentaire