For example, I have a controller with an array property called 'houses' and I am ng-repeat-ing that on a table row with set of radio buttons (true/false, or what have you). What should the model be on those radio buttons such that selecting any of them will set the value on the corresponding item in the model array? I've tried setting the model to something like:
ng-model="array[{{$index}}]"
But that didn't work. I took out the {{ }} and was simply left with the literal string '$index'.
Is this even possible in Angular?
It should work without the curling brackets. I made a Plunker.
$scope.houses = [true, false, true, false, false];
<ul>
<li ng-repeat="house in houses">
Checked: <input type="checkbox" ng-model="houses[$index]" />
</li>
</ul>
{{houses}}
I didn't understood if you have a complex object and wants to set its property (i.e. ng-model="houses[$index].checked". If this is the case, than you should just use the iterator (i.e. ng-model="house.checked"), as house will iterate over each of the array objects.