2016-06-10 2 views
0

에 내 질문에 내 질문 클릭에 그 버튼의 값을 얻기위한 방법이다 그런클릭이 AngularJS와

ng-repeat values with 3 columns in table? - AngularJS에서이 질문에 관련 될 때 버튼의 값을 가져옵니다. ?

여기 내 문제

그것은 하나의 배열에서 작동
<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> 

입니다. 하지만 복수로하지 마십시오

+0

"ng-click ="imClicked (value) "> 배열의 cjmling

+0

Neithe 질문이나 대답에 대답이 들어있는 버튼이 있습니다. 또한 "버튼 값"으로 무엇을 의미하는지도 부정합니다. 그래서 네가 무엇을 요구하는지 모르겠다. 자신의 질문으로 달성하려는 내용을 설명하고 시도한 코드를 보여주십시오. –

+0

''ng-repeat = "행의 열" – ihemant360

답변

1

다음과 같이 시도해 볼 수 있습니다.

<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) }; 
}); 
+0

덕분에 –

-2

는 //이 가정하는 것은 NG-반복 모든 데이터

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

을 보여주기 위해 사용

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

// 다음 컨트롤러에 IT를 통과하고 거기에 가치를 얻을 귀하의 배열입니다.

+0

열이 객체입니다. ng-click = "somefunction (column)"이라고 쓰십시오. – Silvinus