The issue here is that ng-repeat
creates its own scope, so when you do selected=$index
it creates a new a selected
property in that scope rather than altering the existing one. To fix this you have two options:
Change the selected property to a non-primitive (ie object or array, which makes javascript look up the prototype chain) then set a value on that:
$scope.selected = {value: 0};
A{{$index}}
See plunker
or
Use the $parent
variable to access the correct property. Though less recommended as it increases coupling between scopes
A{{$index}}
See plunker