我正在使用ng-repeat顯示角度列表視圖。我能夠顯示列表。實際上,每行有一個單選按鈕,並且我在屏幕上有一個按鈕。我想要獲取所選單選按鈕的對象按鈕點擊。換句話說,如果我選擇第一行單選按鈕,那麼如果我點擊按鈕,我需要得到它的對象,我將如何實現這一點?如何獲得按鈕點擊角度的對象值?
這裏是我的代碼
<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>
更新
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>
您需要$指數傳遞給你的點擊功能。 – user2808895 2014-10-28 05:56:40
在哪裏通過?按鈕是沒有屏幕和每行單選按鈕。一次只選擇一個單選按鈕 – user944513 2014-10-28 05:57:58