Answer the question
In order to leave comments, you need to log in
AngularJS ngRepeat and ngForm - how to refer to a specific contact instance?
There is the following construction:
<ul class="blocks-3" ng-repeat="contact in contacts" ng-form="contactForm">
<li><select class="width-100" ng-change="mask(contact);" ng-model="contact.type" ng-options="o.value as o.displayName for o in options" ></select></li>
<li>
<input type="{{contact.ftype}}" placeholder="{{contact.placeholder}}" name="value" ng-model="contact.value" ui-mask="{{contact.mask}}" required class="width-100" ng-class="{ 'input-error' : contactForm.value.$invalid && submited}" />
<span class="error">{{contactForm.value.$error.text}}</span>
</li>
<li><a href="#" ng-click="removeContact($index);">удалить</a></li>
</ul>
$scope.submit = function(ProfileForm) {
$scope.submited = true;
if (ProfileForm.$valid) {
// тут код когда все нормально
}else{
// ???
// тут хочу пробежаться в цикле по contactForm и выставить где нужно contactForm.value.$error.text для каждого свой
// но почему-то у меня в этом месте всегда только последний экземпляр contactForm
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question