repeat对象传递给函数

repeat对象传递给函数

本文介绍了无法使用ng-click将ng-repeat对象传递给函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

< table class =table> 
< thead>
< tr>< th> pcat< / th>< th> psub< / th>< th> ocas< / th>< th> metal< / th>< th>编辑< /第>< / TR>
< / thead>
< tbody>
< tr ng-repeat =a1 in co>
< td> {{a1.pcat}}< / td>< td> {{a1.psub}}< / td>< td> {{a1.ocas}}< / td>< td> {{a1.metal}}< / td>< td>< input type =hidden/>< input type =buttonid =b1value =编辑ng-click = edit(a1)/>< / td>< / tr>
< / tbody>
< / table>





 $ scope.edit = function(a1){
alert(a1.data);
$ scope.da = a1.data;
};





我的尝试:



i使用ng-init但没有工作

解决方案




  <table  class="table">
            <thead>
                <tr><th>pcat</th><th>psub</th><th>ocas</th><th>metal</th><th>Edit</th></tr>
            </thead>
            <tbody>
<tr ng-repeat="a1 in co">
<td>{{a1.pcat}}</td><td>{{a1.psub}}</td><td>{{a1.ocas}}</td><td>{{a1.metal}}</td><td><input type="hidden"/><input type="button" id="b1" value="Edit" ng-click=edit(a1) /></td></tr>
            </tbody>
        </table> 



$scope.edit = function (a1) {
        alert(a1.data);
        $scope.da = a1.data;
    };



What I have tried:

i used ng-init but didn't worked

解决方案




这篇关于无法使用ng-click将ng-repeat对象传递给函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 03:05