Here is the code snippet I am working with:
<ul class="unstyled">
<li class="card" ng-repeat="user in users">
<form ng-submit="edit()">
<input type="text" ng-model="editname" size="30"placeholder="add name here">
<input class="btn-primary" type="submit" value="edit">
</form>
</li>
</ul>
The card
class will be duplicated based on the items in the users
array. I am trying to ensure that each input has a unique ng-model
so that editing one does not affect the others. I've heard I can use $index
. How can I modify
ng-model="editname"
to become
ng-model="editname + $index"
Is there a better approach for achieving this?