Is there anyway to append the ng-repeat $index to the value of a ng-model directive?
<div class="row" ng-repeat="item in GiantList">
<input type="text" value="" ng-model="saveData.MyProperty+[$index+1]">
</div>
Ideally, this would mean that:
$scope.saveData = [{ "MyProperty1" : "Bob" }, { "MyProperty2" : "Sam" }, { "MyProperty3" : "Chris" }]
I've tried every syntactical combination I can think of to no avail.
Many thanks!
Try
<input type="text" value="" ng-model="saveData['MyProperty'+($index+1)]">
Demo: Fiddle
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With