1
私はIonicを使用していますが、複数のフォームに対してng-repeatを使用しています。私はフォームごとに別々のバリデーションをしたいと思いますが、どのように私がこの作業をすることができるか分かりません。別々のフォームのためのng-repeatでの個別検証
<div class="form-errors"
ng-show="testForm[question.QuestionId].$error.required"
ng-messages="testForm[question.QuestionId].$error"
ng-messages-include="shared/form-errors.html"
ng-if="question.QuestionType == 'QuestionRadio'">
</div>
検証作業を行うための機能ではなく:
コード:
<ion-list ng-if="question.QuestionType == 'QuestionRadio'">
<ion-radio ng-repeat="choice in question.Answers"
ng-model="vm.answer[choice.AnswerId]"
name="{{question.QuestionId}}"
ng-required="vm.answer"
ng-required="!vm.someSelected(vm.answer)">
{{choice.Text}}
</ion-radio>
</ion-list>
エラーメッセージを表示するためのコードを組み合わせる
vm.someSelected = function (object) {
return Object.keys(object).some(function (key) {
return object[key];
});
}
上記のコードはフォームにバリデーションを行いますが、1つのフォームが合格すると、それらのすべてが渡されます悲しい結果。フォームに検証を渡す独自の方法があるように、どうすればよいですか?要素の