My question pertains to an array I am working with:
$scope.answers=["","","",""]
This array contains several empty elements.
<li ng-repeat="item in answers "><input type="text" ng-model="item"/></li>
When running this code, an error indicating that duplicate values are not allowed in ng-repeat is thrown. To resolve this, I modified the code as follows:
<li ng-repeat="item in answers track by $index"><input type="text" ng-model="item"/></li>
Although this change fixed the issue, I am interested in finding a solution without using track by $index, ensuring that sorting functionality remains intact.
If anyone has any insights or suggestions on how to achieve this, please share your ideas.