Answer the question
In order to leave comments, you need to log in
Angular pristine in ng-repeat: why doesn't the code work?
Please tell me why the code is not working.
<table class="table table-hover">
<tr ng-repeat="contact in contacts">
<form name="contactEditForm{{$index}}">
<td>
<input type="text" class="form-control" placeholder="ФИО" ng-model="contact.name">
<input type="text" class="form-control" placeholder="Дожность" ng:model="contact.position" >
<button ng-hide="contactEditForm{{$index}}.$pristine" class="save btn btn-primary" ng:click="editContact()">Сохранить</button>
</td>
<td>
<input class="form-control" placeholder="Email" ng:model="contact.email" >
</td>
<td>
<input type="text" class="form-control" placeholder="Телефон" ng:model="contact.phone" >
<input type="text" class="form-control" placeholder="Мобильный" ng:model="contact.mobile" >
</td>
<td><textarea type="text" class="form-control" placeholder="Описание" ng:model="contact.feature" ></textarea></td>
<td><span class="glyphicon glyphicon-remove" ng:click="deleteContact(contact.id)"></span></td>
</form>
</tr>
</table>
Answer the question
In order to leave comments, you need to log in
contactEditForm{{$index}}.$pristine
- syntax error. Such an expression is not allowed in JavaScript.
Google the answer for you: stackoverflow
If you are too lazy to read, then without creating anything new, you can do it this way:
<tr ng-repeat="contact in contacts">
<form name="contact.contactEditForm">
...
<button ng-hide="сontact.contactEditForm.$pristine" class="save btn btn-primary" ng:click="editContact()">Сохранить</button>
...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question