I am displaying a list view in angular using ng-repeat .I an able to display list .Actually there is one radio button in each row .And I have one button on screen .I want to get object of selected radio button on button click .In other words If I select first row radio button then if I click button I need get it object how I will achieve this ?
here is my code
<table>
<tr id="$index"ng-repeat= "a in data " ng-click="getselectedRow(a)">
<td> {{a.condidateID}} </td>
<td> {{a.condidateName}} </td>
<td> {{a.territory}} </td>
<td> {{a.voteCount}} </td>
<td> <input type="radio" name="chickenEgg" value="egg" ng-model="chekratiovalue"></td>
</tr>
</table>
<button style="left: 40%;top: 40%;float: left;position: relative" ng-click="voteForPerson()">Vote</button>
Update
function userdetail($scope,$http,$location,$routeParams){
console.log(JSON.parse($routeParams.userDetail));
var userDetail=JSON.parse($routeParams.userDetail);
$scope.data=userDetail.data;
console.log($scope.data);
console.log($scope.data);
$scope.changeEvnt = function(index) {
$scope.activeRow = index;
alert( $scope.activeRow);
}
$scope.voteForPerson = function() {
var selcted = $scope.data[activeRow ];
}
}
<table>
<tr id="$index"ng-repeat= "a in data " ng-click="getselectedRow(a)">
<td> {{a.condidateID}} </td>
<td> {{a.condidateName}} </td>
<td> {{a.territory}} </td>
<td> {{a.voteCount}} </td>
<td> <input type="radio" name="chickenEgg" value="egg" ng-model="chekratiovalue" ng-change="changeEvnt($index)"></td>
</tr>
</table>
<button style="left: 40%;top: 40%;float: left;position: relative" ng-click="voteForPerson()">Vote</button>