javascript - how to get object value on button click in angular? -
I am displaying a list view in angular using ng-repeat. I was able to display the list. Actually a radio button is on each line and I have a button on the screen. I want to get the object of the selected radio button when clicking the button. In other words, if I select the first line radio button, if I click on the button If I click, I want this object how do I get it?
Here's my code
& lt; Table & gt; & Lt; Tr id = "$ index" ng-repeat = "one in data" ng-click = "mix-selection road (a)" & gt; & Lt; TD & gt; {{A.condidateID}} & lt; / Td> & Lt; TD & gt; {{A.condidateName}} & lt; / Td> & Lt; TD & gt; {{A.territory}} & lt; / Td> & Lt; TD & gt; {{A.voteCount}} & lt; / Td> & Lt; TD & gt; & Lt; Input type = "radio" name = "chicken euget" value = "egg" ng-model = "checkered" & gt; & Lt; / Td> & Lt; / TR & gt; & Lt; / Table & gt; & Lt; Button style = "left: 40%; top: 40%; float: left; position: relative" ng-click = "votefire ()" & gt; Vote & lt; / Button & gt;
Update
function user's scrapped ($ scope, $ http, $ location, $ routeParams) {console.log (JSON .parse ($ routeParams.userDetail)); Var userDetail = JSON .pars ($ routeParams.userDetail); $ Scope.data = userDetail.data; Console.log ($ scope.data); Console.log ($ scope.data); $ Scope.changeEvnt = function (index) {$ scope.activeRow = index; Warning ($ scope.activeRow); } $ Scope.voteForPerson = function () {var selcted = $ scope.data [activeRow]; }} & Lt; Table & gt; & Lt; Tr id = "$ index" ng-repeat = "one in data" ng-click = "mix-selection road (a)" & gt; & Lt; TD & gt; {{A.condidateID}} & lt; / Td> & Lt; TD & gt; {{A.condidateName}} & lt; / Td> & Lt; TD & gt; {{A.territory}} & lt; / Td> & Lt; TD & gt; {{A.voteCount}} & lt; / Td> & Lt; TD & gt; & Lt; Input type = "radio" name = "chicken egg" value = "egg" ng-model = "skin light" ng-change = "change event ($ index)" & gt; & Lt; / Td> & Lt; / TR & gt; & Lt; / Table & gt; & Lt; Button style = "left: 40%; top: 40%; float: left; position: relative" ng-click = "votefire ()" & gt; Vote & lt; / Button & gt;
add ng-change
instructions,
< Pre> & lt; Input type = "radio" name = "chickenEgg" value = "egg" ng-model = "chekratiovalue" ng-change = "changhevant ($ index)" & gt;
In the administrator
$ scope.chengeEvnt = function (index) {$ scope.activeRow = index; // get index while changing radio button) $ scope.voteForPerson = function () {var selected = $ scope.data [$ scope.activeRow]; // Get the line of selected radio buttons using the `` $ scope.activeRow` function}
Comments
Post a Comment