Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

My question Related to this Question at ng-repeat values with 3 columns in table? - AngularJS

Then my Question is How to Get the Value of that button on click. ?

Here is My Problem

 <input type='text' ng-model="mydata" />

  <span ng-bind="$parent.$eval(mydata)"></span> 




 $scope.buttons =[ [0,1,2,3,4],
                    [5,6,7,8,9]
                  ];




<tr ng-repeat="row in buttons">
  <td ng-repeat= "button in row"><button class="btn btn-primary" ng-click ="$parent.mydata = $parent.mydata.toString() + button">
    {{button}}</button></td>
  </tr>

It Works on a single Array. But in multiple it doesn't

share|improve this question
    
This should work.. <span ng:repeat="(index, value) in array" ng-click="imClicked(value)"> – cjmling 19 mins ago
    
Neither the question nor its accepted answer has any button in it. It's also unclean what you mean with "button value". So I have no idea what you're asking. Explain, in your own question, what you're trying to achieve, and show the code you tried. – JB Nizet 16 mins ago
    
what about ng-repeat="column in row" – ihemant360 15 mins ago
    
Stop using $parent. Call functions on your $scope, and put the code you want to execute in that function. The parent scope of the inner ng-repeat is the scope of the outer ng-repeat, not the scope of the controller. – JB Nizet 5 mins ago

You can try something like this.

 <body ng-app="myApp" ng-controller="myCtrl">
    <div ng-repeat="value in array">
            <button ng-click=myFunction(value,$index)> MyButton</button>
    </div>
 </body>

app.controller('myCtrl', function ($scope) {
$scope.myFunction = function(val,index) {
console.log(val) };
});
share|improve this answer

//assuming this is your array

$scope.data = [
    ["opt1", "opt2", "opt3"],
    ["opt1", "opt2", "opt3"],
    ["opt1", "opt2", "opt3"]
];

// using ng-repeat to show all data

<table>
    <tr ng-repeat="row in data">
        <td ng-repeat="column in row" ng-click="somefunction('{{column}}')">{{column}}</td>
    </tr>
</table>

THEN PASS IT TO THE CONTROLLER AND GET THE VALUE THERE..

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.